Re: problem with do shell script
Re: problem with do shell script
- Subject: Re: problem with do shell script
- From: Doug McNutt <email@hidden>
- Date: Tue, 28 Jun 2011 13:15:04 -0600
At 14:45 -0400 6/28/11, John McClintock wrote:
>Greetings Scripters,
>
>I'm having a problem with a script I've been using for several years and hope it's a workstation issue. The script collects images from http://www.goes-arch.noaa.gov/ and assembles them into a QuickTime Movie. The script breaks on the following:
>
>set shell_string to "curl -O http://www.goes-arch.noaa.gov/ECIR111790745.GIF "
>do shell script shell_string
>
>The error says "failed to create the file" and "failed to write body" - it's not writing the file. The result line is "curl -O http://www.goes-arch.noaa.gov/ECIR111790745.GIF " and this seems to be well-formed and works in Terminal. The image does exist on the server (they are stored for 30 days and it exists today), and actually the script should write a blank file even if the file doesn't exist on the server. It feels like a permissions issue.
>
The -O option, with a capital O, asks curl to use the name of the distant file, ECIR111790745.GIF in this case, and save the download with that name in the current working directory.
When you "do shell script" you really don't know what the current directory is. A new bash shell is invoked and you can't depend on it to read your profile or anything else. Even your $PATH variable is not predictable.
I'd suggest using -o path_to_file, with a small o, instead. That way you can use a fully defined path to a directory you know has the right permissions. You can also put two commands into the script separated with a semicolon, with the first being a cd to set the working directory. You cannot set the directory in an earlier do shell script - there is no memory.
You might also have a look at curl's -k option which allows curl to read instructions from a prepared text file.
And, as always, quoted form of ( ), is a good prophylactic whenever you have filenames that might need escaping of characters that are special either in the shell or in AppleScript itself.
--
--> From the U S of A, the only socialist country that refuses to admit it. <--
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden