do shell script "curl --cookie-jar ~/Desktop/testcookie 'http://www.example.com/login?username=bob&password=pass'"
do shell script "curl --cookie ~/Desktop/testcookie 'http://www.example.com/search?q=something'"
You might want to also look at the HTTP request to make sure you aren't getting redirected as part of the request. You may need to put a –L flag in your second curl command so that it follows the redirect.
Jim
Date: Thu, 11 Apr 2013 16:14:57 +0200
From: Håvard Graudo
I have problems using cookies with curl via do shell script.
I want to login and get a cookie, then send commands back to the server, including the cookie.
This works in Terminal:
--> login OK, sessionID: 1i7nm0ch6pphezdqkulhdub30 blah blah
--> returns my search. all nice and dandy
The information stored in the cookie is a plain Netscape HTTP Cookie File.
However if I do the SAME THING using 'do shell script' it fails:
--> login OK, sessionID: s04988pspn6otuaaz6xeuooy blah blah
-- NOT LOGGED IN
What works in Terminal does not with 'do shell script'.
Can someone help me in the right direction here?
Thank you
Håvard