Why does my curl command fail when run through applescript but work fine when I run directly in a terminal? I am trying to write an applescript to control an installed projector using it's built in web interface. I have a curl command that pings the appropriate URL and can controll the projector as needed from the command line, when I build this into an applescript (required by my show control software) I
My applescript currently looks like this:
set theUrl to &quot;http://192.168.0.103/cgi-bin/proj_ctl.cgi?key=shutter_on&amp;lang=e&amp;osd=on&quot;
set theUsername to &quot;dispadmin&quot; -- set this to the username for the projector
set thePassword to &quot;password&quot; --set this to the password for the projector

set myFile to (POSIX path of (path to temporary items)) &amp; &quot;curl_downloaded_file.xml&quot;

set curlScript to &quot;/usr/bin/curl --connect-timeout 1 --anyauth --user&quot; &amp; &quot; &quot; &amp; theUsername &amp; &quot;:&quot; &amp; thePassword &amp; &quot; -L &quot; &amp; theUrl &amp; &quot; -o &quot; &amp; myFile

display dialog &quot;my variable: &quot; &amp; curlScript

do shell script curlScript

The display dialog line is for debugging to show what the curl command will look like, when I run this I get the following:
/usr/bin/curl --connect-timeout 1 --anyauth --user dispadmin:password -L http://192.168.0.103/cgi-bin/proj_ctl.cgi?key=shutter_on&amp;lang=e&amp;osd=on -o /private/var/folders/zs/f1hpkd2x281fvzyh4zd5dpcw0000gn/T/TemporaryItems/curl_downloaded_file.xml

Which seems correct. If I add quote marks around the URL I can run this command in the terminal with no issues and get the desired effect, however the Applescript will then continue to spit out the following error:
error &quot;sh: -o: command not found
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   350  100   350    0     0  38888      0 --:--:-- --:--:-- --:--:-- 38888

100   267    0   267    0     0   5235      0 --:--:-- --:--:-- --:--:--  5235&quot; number 127

This looks like curl is running but it doesn't hit the projector's web server to trigger the controll, also the error &quot;sh: -o: command not found makes me think that the command isn't being parsed/passed correctly.
What am I doing wrong here?
While
http://192.168.0.103/cgi-bin/proj_ctl.cgi?key=shutter_on&amp;lang=e&amp;osd=on

works fine in a browser, it does not in a shell.
To resolve the issue you need to quote the URL.
In set curlScript to ... change theUrl to either theUrl's quoted form or: quoted form of theUrl