Is there a way to send variables from an Applescript to a cgi script somewhere on a server on the net? The result should be the same as manually filling in an HTML form and then submitting it to that cgi script. Or for that matter, can one send variables to an HTML form and then submit it? You get the idea of what I need…
Sure! It’s pretty easy:
set remoteApp to "http://www.server.com/app.cgi"
set URLEncodedVars to "var1=jumbo&var2=blank%20space"
do shell script "curl -d " & URLEncodedVars & space & remoteApp
You may need cookies or a referrer. Just go to a Terminal window and type “man curl” for more options…
- If you use GET data, it is as easy as: do shell script “curl http://www.server.com/app.cgi?var1=a&var2=b”
That looks good! thanks! What’s the syntax if I want to simulate a checkbox that was chosen in the submitted form? something ilke var1=true?