Re: do shell script, curl and cookies
Re: do shell script, curl and cookies
- Subject: Re: do shell script, curl and cookies
- From: Doug McNutt <email@hidden>
- Date: Thu, 11 Apr 2013 09:59:00 -0600
At 16:14 +0200 4/11/13, Håvard Graudo wrote:
>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:
>curl --cookie-jar zecookie.txt 'http://www.example.com/login?username=bob&password=pass'
>--> login OK, sessionID: 1i7nm0ch6pphezdqkulhdub30 blah blah
>curl --cookie zecookie.txt 'http://www.example.com/search?q=something'
>--> 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:
>do shell script "curl --cookie-jar zecookie.txt 'http://www.example.com/login?username=bob&password=pass'"
>--> login OK, sessionID: s04988pspn6otuaaz6xeuooy blah blah
>do shell script "curl --cookie zecookie.txt 'http://www.example.com/search?q=ssomething'"
>-- NOT LOGGED IN
>
>What works in Terminal does not with 'do shell script'.
>
Do Shell Script always starts a new session and thus loses all of your environment.
Curl has do be doing something to preserve the cookie between calls and I don't know what it is but I'm pretty sure successive calls via Do Shell Script will mess it all up.
You could try making up a file with all of the curl calls as a UNIX script. Then one Do Shell Script pointing to it.
You can also script Terminal.app with things like Tell Terminal to do something in a named window. When you point your next shell line to the same window things will be remembered.
A question about just how curl handles storage of a SessionID cookie would probably get answered quickly here:
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users> <mailto:email@hidden?subject=subscribe>
I wouldn't bother them with AppleScript though.
--
--> A fair tax is one that you pay but I don't <--
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden