Applescript Shell Curl Script

Posted on
Mon Nov 25, 2013 11:23 am
MrJeffreyGee offline
User avatar
Posts: 74
Joined: Apr 26, 2011
Location: United States

Applescript Shell Curl Script

I've been uploading weather data to the SQL database on my webserver using Applescript and Safari, which works fine. It's slow and CPU intensive, so I'm trying to convert over to using the curl command and I'm having trouble. If I type in this URL directly in a browser it works and the data is injected into the database, but when I do it with curl in an Applescript it doesn't work. I don't understand why. I don't get any errors and the output I get back in Terminal is just the code from the webpage. If anyone's got a clue why this is happening I'd appreciate some help.


This works in a browser
Code: Select all
http://www.mywebsite.com/input.php?data1=text&data2=text&data3=text



This doesn't work in an applscript
Code: Select all
tell application "Terminal"
   if (count of windows) is 0 then
      do shell script "/usr/bin/curl -d 'data1=text&data2=text&data3=text' http://www.mywebsite.com/input.php "
   else
      activate
      do shell script "/usr/bin/curl -d 'data1=text&data2=text&data3=text' http://www.mywebsite.com/input.php " in window 1
   end if
end tell

Posted on
Tue Nov 26, 2013 12:23 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Applescript Shell Curl Script

drop the tell activate terminal ... etc just do


do shell script "curl -d 'data1=text&data2=text&data3=text' http://www.mywebsite.com/input.php "

nothing else

Posted on
Tue Nov 26, 2013 6:10 am
MrJeffreyGee offline
User avatar
Posts: 74
Joined: Apr 26, 2011
Location: United States

Re: Applescript Shell Curl Script

kw123 wrote:
drop the tell activate terminal ... etc just do


do shell script "curl -d 'data1=text&data2=text&data3=text' http://www.mywebsite.com/input.php "

nothing else



I've tried that too, but the data doesn't get injected into the sql database. It's really strange. I can't seem to get anything injected into the database with curl.

Posted on
Tue Nov 26, 2013 8:08 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Applescript Shell Curl Script

Have you tried debugging on the server side to see exactly what is getting passed in both the working and non-working cases? Your curl POST request looks good to me, but there must be something different about the browser versus curl case.

Image

Posted on
Wed Nov 27, 2013 4:32 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Applescript Shell Curl Script

do you have to enter userid and password when on the browser? I had the same problem


Code: Select all
   do shell script " curl -u aaaaa:xxxxx -d  \"ReplySuccessPage=image.htm&ReplyErrorPage=errrimg.htm&BrightnessControl=64&ContrastControl=64&SaturationControl=64&AntiFlickerEnable=1&Mirror=0&ConfigSystemStream=Save\" http://192.168.1.78/setSystemStream  >/dev/null 2>&1 &" 


this is setting some parameters on a web camera.
( aaaa xxxx are the userid and passwords)

you should try wireshark or the chrome debugger page to check what traffic actually goes over the wire.


Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron