curl-users
Re: newbie authentification cookie redirection
Date: Thu, 28 Aug 2003 02:00:53 -0500
Try it with:
-b cookiefile -c cookiefile
in every curl call. The -b arg tells curl to send cookies from the file
(if appropriate) and the second tells it to save any collected cookies
just before exiting. This is the important bit you're missing - you're
not saving and re-sending cookies...
Ralph Mitchell
Laurent Demaret wrote:
> Hello,
>
> I'm a newbie, macos user, trying to make a script in order to
> download automatically a file on a server. With an executable
> script. But I'm newbie in all those things.
> So i found lynx-ssl and its trace mode to see what I send the
> server each time.
> It starts by a request that gives me a cookie and a redirection url
> and I'm supposed to send back cookie and use redirection. Of course.
>
> I've tryed a few way but it does not work and I'm now at the point I
> mess everythings :-/
>
> Here is the line that should work and does not
>
> curl -D "D_Curl4Seph" -b -e -L
> 'http://mysite.com/DirOuone/login.php?login=123456789&pass=Mypass' -o
> 'SoDesiredFile
> 'https://mysite.com/DirOuone/Action.php?choix=2&Annee=2003&action=Excel'
> unmatch ..
>
> I was better when I used several lines :
>
> With the following line
>
> curl -v -D 'AQUEJEVOUDRAIS2' -b -L -e -u
> "http://mysite.com/DirOuone/login.php?login=123456789&pass=Mypass"
>
> I get the Header :
> HTTP/1.1 302 Found
> Date: Wed, 27 Aug 2003 12:58:48 GMT
> Server: Apache/1.3.14 (Unix) PHP/4.0.3pl1 mod_ssl/2.7.1 OpenSSL/0.9.6
> X-Powered-By: PHP/4.0.3pl1
> Set-Cookie: PHPSESSID=f0b56becb2468ab5a6af406f602dbdf1; path=/
> Expires: Thu, 19 Nov 1981 08:52:00 GMT
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
> pre-check=0
> Pragma: no-cache
> Location: https://mysite.com/indexps.php
> Transfer-Encoding: chunked
> Content-Type: text/html
>
> But I have not been able to make the second request by a simple
> curl -v -D 'AQUEJEVOUDRAIS2' -b -L -e -o
> "https://mysite.com/DirOuone/action.php?choix=2&Annee=2003&action=Excel"
>
> It's sound very good :
>
> HTTP/1.1 200 OK
> Date: Wed, 27 Aug 2003 13:01:41 GMT
> Server: Apache/1.3.14 (Unix) PHP/4.0.3pl1 mod_ssl/2.7.1 OpenSSL/0.9.6
> X-Powered-By: PHP/4.0.3pl1
> Set-Cookie: PHPSESSID=02ec4068225ddd9d2ef3fd171709d047; path=/
> Expires: Thu, 19 Nov 1981 08:52:00 GMT
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
> pre-check=0
> Pragma: no-cache
> Connection: close
> Content-Type: text/html
>
> But it should be a "Content-Type" : Application/OctetStream (it is in
> lynx trace) and the text/html says "User do not exist" wich I know is
> false, I'm a regular user that can get his data via a browser.
>
> Could you tell me how I should write that ?
>
> With lynx it sends a request at the redirection
> "https://mysite.com/indexps.php "and after the second url that makes
> the server to send a file type Application/OctetsStream I need to
> store on my disk. Should I do that ?
>
> I'll try now anyway :-)
>
> Well, it seemed to work fine but when I tried to get my file with the
> line I used before server says again "User does not exist" (and
> still no new file on my home)
>
>
> Thanks in advance if you can help me, I'm not a professional
> developer :-/
>
>
> Laurent Demaret
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-08-28