1

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 "http://192.168.0.103/cgi-bin/proj_ctl.cgi?key=shutter_on&lang=e&osd=on"
set theUsername to "dispadmin" -- set this to the username for the projector
set thePassword to "password" --set this to the password for the projector

set myFile to (POSIX path of (path to temporary items)) & "curl_downloaded_file.xml"

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

display dialog "my variable: " & 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&lang=e&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 "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" 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 "sh: -o: command not found makes me think that the command isn't being parsed/passed correctly.

What am I doing wrong here?

1
  • can you try putting the URL in quotes ?
    – anki
    Aug 19 '20 at 14:39
3

While

http://192.168.0.103/cgi-bin/proj_ctl.cgi?key=shutter_on&lang=e&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

1
  • This has fixed the issue, Thanks!
    – RobbG
    Aug 19 '20 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .