cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Redirect problem?

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Thu, 14 Dec 2006 22:42:09 -0600

On 12/14/06, Phill Edwards <philledwards_at_gmail.com> wrote:
>
> I'm new to curl and I'm trying to write some curl commands that will
> log into a web site that I use and return a small piece of data from
> my membership page.
>
> The form action that I call is called start.php. If I knock up a page
> in notepad with this form in it and run that in a browser I can log on
> manually by keying in the fields - so I don' t think the referer is
> being checked.
>
> I _think_ the web site works by running start.php which does some sort
> of validation (like checking username and password) and then redirects
> off to a page called member.php - this is where I end up when running
> this in a browser. How can I make this happen through curl? I've tried
> just calling start.php like this:
>
> $ curl --location -s -D - -d "user=987654&password=12345"
> http://www.freecall.net.au/start.php
>
> and I've tried embedding a call to member.php in the call to start.php
> like this:
>
> $ curl -s -b --location "`curl -s -D - -d "user=987654&password=12345"
> http://www.freecall.net.au/start.php | grep Set-Cookie | sed
> 's/Set-Cookie: //'`" "https://www.freecall.net.au/member.php"
>
> While the embedded command does end up at member.php, something isn't
> right because my membership info isn't coming back in the html - it's
> behaving as if the authentication failed and it doesn't know which
> member to display data for.
>
> Hope this makes sense to someone!
>

You might need to be handling cookies:

  curl -b cookies -c cookies -s --location .....

If all else fails, install LiveHTTPHeaders in Firefox and watch what happens
when you hit the site in the browser.

Ralph Mitchell
Received on 2006-12-15