Page 1 of 1

Execute Command - curl

Posted: Mon Aug 15, 2022 11:28 pm
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.

Re: Execute Command - curl

Posted: Tue Aug 16, 2022 8:09 am
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

Re: Execute Command - curl

Posted: Tue Aug 16, 2022 8:27 am
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.

Re: Execute Command - curl

Posted: Tue Aug 16, 2022 11:05 am
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.

Re: Execute Command - curl

Posted: Tue Aug 16, 2022 4:58 pm
by RunDontStop
HTTP request was a great solution. And I will watch the webinar. Thank you.