9 Replies Latest reply: Apr 14, 2012 2:43 AM by Donald Collier1
Donald Collier1 Level 1 Level 1 (25 points)



I am having a real job trying to get  cURL to work in an apple script in Lion. A number of people have posted an Apple script so you can dial numbers throughyour phone extention on a Snom phone. Where as it worked onLeopard it now wont work on Lion and I cant work out why. The only thing I can think of is that cURL isnot installed by default can any one help?


The section of code I know NOT be working (I'v tested the rest). Its part of a perform action . The expression

set errorCode to do shell script "curl \"" & theURL & "\"" seems to do nothing.



set theURL to "http://" & mySnomLogin & ":" & mySnomPassword & "@"

set theURL to theURL & mySnomPhoneAddress & "/command.htm?number=" & cleanedNumber


-- Use curl to hit the URL and dial the number 

set errorCode to do shell script "curl \"" & theURL & "\""



display dialog "Info: Dialing " & numToDial buttons {"OK"}


--If there was an error, return a message.

if (characters 1 thru 3 of errorCode) as string is not equal to "000" then

display dialog "Error: " & errorCode buttons {"OK"}

end if



Thanks D

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    That would be a very easy thing for you to check out, no? Just open a terminal and type curl. What happens?


    (to save you the suspense I'll tell you, it's there)


    What error messages are you getting? What is happening that makes you think the curl command isn;t working?

    Have you tried putting in some print or log statments to tey and see what is going on?

  • Donald Collier1 Level 1 Level 1 (25 points)

    Thanks This is the result I get :-


    curl: try 'curl --help' or 'curl --manual' for more information



    "Curl --Manual" does provide the manual so that is there


    I get appropriate responce's from the script parts before the extract I have posted above.  I have put in an eco command and I have commented out the "if" to see the "error" always but it does not even beep so something defiantly appears wrong with the line or the outcome:

    set errorCode to do shell script "curl \"" & theURL & "\""


    hence my wondering if cURL had been installed.


    You can find the full script in template form here

  • Donald Collier1 Level 1 Level 1 (25 points)

    I have made this even simpler as follows:


    An apple script containing this:

    "curl https://[IP number of the phone]/index.htm?number=69"


    (69 is a valid internal extention) generates nothing


    however when you type into a browser window it dials perfectly!



  • Barney-15E Level 8 Level 8 (44,255 points)

    What happens if you do this in Terminal:



    How about "open location" in applescript?

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    Nothing obviously wrong with the script.  When you run the script does it hang or complete and your phone isn't  dialed? If so does the errorCode have anything in it?


    Unfortunately there is no way for me to run this without dialing your phone so troubleshooting  it is difficult.


    As Barney suggested what happens if you run curl from the command line? I can tell you that curl in Lion works as I have a few scripts that make use of it and they work.

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    Another possibility is that non-browser access is being blocked somewhere along the line.


    If using curl from the command line fails also I'd look into this possibility.

  • billcole Level 1 Level 1 (35 points)

    Barney's suggestion will probably show you the problem, which I suspect is a certificate verification problem.


    The 'curl' shipped with Lion has https support that requires server certificates to verify correctly using the default CA trust settings OR using a CA database you provide it ('man curl' for details) OR trusting all certs if you give it the -k or --insecure arguments.


    Also note that unlike an actual shell script, the AppleScript 'do shell script' function returns the output of the shell commands it is given  *NOT THE RETURN VALUE* It also does not return diagnostic output that  sent to the "standard error" stream. That's why running your command in a real shell is going to tell you more.


    Message was edited by: billcole added last paragraph.

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    Good point.


    But now the OP has me confused. In his first post (and in the script he linked to) the protocol is http. But in the second post he used https. So which should it be?

  • Donald Collier1 Level 1 Level 1 (25 points)

    Thank you all for your help.


    Barney-1SE suggestion use terminal and billcole comments on certificates that helped pave the way.


    In the end it was to do with the browser caching the password for the phone so it used that, hiding the fact that we had put the wrong password ( but still a valid password for that phone) into the script!


    SNOM phones are really great but they have loads of different passwords!!