Curl error & question

Howdy,

I am trying to use curl to download a zip file using a URL that is emailed to me.
I want to save the file to a drive that is not my system drive.
Here is the part of my script that uses curl:


set jobTitle to "Title"
set destinationFolder to "//Production1/'_Customer Uploads'/" & jobTitle & "/"
set download to "http://www.northstar.com/files/june18_06_9D7NYA.zip"
with timeout of 30 seconds
	do shell script "curl " & download & "-o" & destinationFolder & jobTitle & ".zip"
end timeout

When I run the above-posted part of the script, I receive this error:

"

400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.

The request line contained invalid characters following the protocol string.

"

Does anyone know what I am doing wrong?

Many thanks in advance

Hi,

if the page is in a restricted area, you have to login.
This is quite complicated with curl and Safari, because
for a login via cookie you need a certain plain text file, which Safari doesn’t create.
There was a thread with this topic a few month ago.

Note: the AppleScript timeout command works only with Apple Events sent to an application,
it’s useless for shell calls

Thanks very much for the reply & the timeout tip.

I got the download to work now, but now I am puzzled about the difference between the following 2 scripts, of which the first one works and the second one does not:


--this script works
set jobTitle to "Title"
--set destinationFolder to "/'Prepress Shared'/"
set download to "http://www.northstar.com/files/june18_06_9D7NYA.zip"

do shell script "curl " & quoted form of download & " -o /'Prepress Shared'/" & quoted form of jobTitle & ".zip"

--this script does not work "Failed to create the file..."
--in this script, I called the quoted form of my destination folder instead of stating it directly in the do curl
(*set jobTitle to "Title"
set destinationFolder to "/'Prepress Shared'/"
set download to "http://www.northstar.com/files/june18_06_9D7NYA.zip"

do shell script "curl " & quoted form of download & " -o " & quoted form of destinationFolder & quoted form of jobTitle & ".zip"
*)

Hi molinus,

In the first script, which works, you are using this expression:


/'Prepress Shared'/" & ...

But in the second script, which does not work, you are using this expression:


set destinationFolder to "/'Prepress Shared'/"
quoted form of destinationFolder & ...

There you are actually quoting quotes!

So try this instead:


set jobTitle to "Title"
set destinationFolder to "/'Prepress Shared'/"
set download to "http://www.northstar.com/files/june18_06_9D7NYA.zip"

do shell script "curl " & quoted form of download & " -o " & destinationFolder & quoted form of jobTitle & ".zip"

HTH!

Thanks Martin :slight_smile:
I couldn’t see the forest for the trees :rolleyes: