Execute Command - curl

Post Reply
RunDontStop
Member
Posts: 51
Joined: Mon Apr 05, 2021 8:03 pm

Execute Command - curl

Post by RunDontStop »

Please forgive me - I have a complete lack of knowledge. Working on a Mac and using Terminal.

My job starts off with a url address. The url is always a pdf. When saved manually from a browser, the pdf extension is not appended. An example:

http://MISapp/MI/viewreport.ashx?path=D ... &jobid=114

If I append ".pdf" when saved from Safari, I have a PDF.

Knowing this I plug this command into Terminal:

curl -O 'http://MISapp/MI/viewreport.ashx?path=D ... id=114.pdf'

And I end up with a PDF in my user folder.

Now, to set up Execute Command in Switch. I have tried everything. For "Command or Path", my best guess is:

curl

OR

/usr/bin/curl

For the arguments, I have no clue. From what I see, I don't need to pass on an input file, because the command does not require one. So what does that mean for "%1"? Does it need to be blank?

With the command run as is from Terminal, the output PDF file is in my user folder. If possible I need Switch to pick this up so it continues on in the flow. I guess this happens in the "%2" argument?

I have tried everything and no luck. What I want is the url to be variable, depending on the job. I will pick up the Job Number and Job ID as private data keys and include those in the url part of the argument. But I simply cannot get a result even without variables. When I put a fixed address in the arguments, I get nothing. But it does work from Terminal.

Any help understanding is appreciated. Thank you.
User avatar
JimmyHartington
Advanced member
Posts: 280
Joined: Tue Mar 22, 2011 7:38 am

Re: Execute Command - curl

Post by JimmyHartington »

How is the job triggered in Switch?

Because if you have the data you need to change in the url, then you can use variables in the "Arguments".
Image

So arguments could look like this:

Code: Select all

'http://misapp/MI/viewreport.ashx?path=D:%5CMIS%5CApproot%5CPrimo%5CDocuments%20US%5CStandardWorksInstruction%20test.rpt&jobno=[Job.PrivateData:Key="jobno"]&jobid=[Job.PrivateData:Key="jobid"]' -o '%2' 
As you can see there are private data, which replaces parts of your URL and I define the output as %2, which is replaced with where Switch outputs the file.

And if you struggle with the Execute Command (which I often does :) ), I will suggest you watch the latest webinar about Switch.
https://learning.enfocus.com/course/view.php?id=459
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Execute Command - curl

Post by freddyp »

I would suggest to use "HTTP request" to download the file and if it is missing an extension just follow up with "Rename job" to add it.
User avatar
JimmyHartington
Advanced member
Posts: 280
Joined: Tue Mar 22, 2011 7:38 am

Re: Execute Command - curl

Post by JimmyHartington »

freddyp wrote: Tue Aug 16, 2022 8:27 am I would suggest to use "HTTP request" to download the file and if it is missing an extension just follow up with "Rename job" to add it.
I forgot that is an option.
Then you still need to change the url to include the variables as well.
RunDontStop
Member
Posts: 51
Joined: Mon Apr 05, 2021 8:03 pm

Re: Execute Command - curl

Post by RunDontStop »

HTTP request was a great solution. And I will watch the webinar. Thank you.
Post Reply