cURL / Mailing Lists / curl-users / Single Mail

curl-users

Login script doesn't work - please help

From: <sc2000_at_qwest.net>
Date: Wed, 5 Jan 2005 15:17:00 -0800

Good day and happy & successful 2005 to all of you!

I wonder if one of you CURL experts can help me with the following problem:

I would like to use CURL to check regularly on my pages on Amazon.com.
Of course this requires two calls: One to log-in, one to the profile page.
I thought all I need to do is
1. send my login credentials with the "-d" switch,
2. capture the issued cookie(s) to a file with a "-D" switch, and then
3. with second CURL call send the cookie back with the "-b" switch.

Sounds easy but it doesn't work. I can log-in successfully but when
accessing my
order URL the server sends me back the login page again; not the requested
page.

I have spent hours trying to figure out why with no result;
hence this my desperate call for help.

Here are the details:

The sign-in page is here:
http://s1.amazon.com/exec/varzea/register/login/103-3412348-6876469

The ACTION line in the <FORM> is:

<form name="login"
action="http://s1.amazon.com/exec/varzea/register/process-login/103-3412348-
6876469" method="post" onSubmit="return(login_onSubmit());">

The <FORM> inputs are:
  login-standard-server=1
  pipeline-type=payer
  input-login-customer=existing
  input-login-email={USER}
  password={PASSWORD}

So I assemble them into one-line command as follows:

curl -A Mozilla/4.0+(compatible;+MSIE+6.01;+Windows+98) -d
"login-standard-server=1&pipeline-type=payer&input-login-customer=existing&i
nput-login-email={USER}&password={PASSWORD} -D GetCookie
"http://s1.amazon.com/exec/varzea/register/process-login/103-3412348-6876469
"

Note: Instead of {USER} and {PASSWORD} I send in my real username and
password, of course.

In return, the server sends cookies (captured to local file), and also a
HTML page confirming I am logged in (which is not captured).

The cookie file looks like this:

HTTP/1.1 200 OK
Date: Mon, 03 Jan 2005 22:52:51 GMT
Server: Stronghold/2.4.2 Apache/1.3.6 C2NetEU/2412 (Unix)
Set-Cookie: session-id=103-3412348-6876469; path=/; domain=.amazon.com;
expires=Monday, 10-Jan-2005 08:00:00 GMT
Set-Cookie: session-id-time=1105344000; path=/; domain=.amazon.com;
expires=Monday, 10-Jan-2005 08:00:00 GMT
Cneonction: close
Transfer-Encoding: chunked
Content-Type: text/html

Seems pretty straight-forward, except perhaps for the misspelled
"Cneonction: close" line (I have also tried to correct it before sending the
file back to the server; it made no difference).

Then I make the second one-line CURL call to the page I want to save on my
computer:

curl -A Mozilla/4.0+(compatible;+MSIE+6.01;+Windows+98) -b GetCookie -o
MyPage.HTM
"http://s1.amazon.com/exec/varzea/ts/{MYPROFILE}/103-3412348-6876469"

Again, in place of {MYPROFILE} I send in my real profile number.

But it fails - I get back a page asking me to sign-in again!
I've tried all I know but no result; clearly I do not know enough :-((

Either I'm doing something wrong, or perhaps I am missing something related
to a small snippet of Javascript contained in the "login" page above the
<FORM> data, which looks like this:

  <script language="Javascript" type="text/javascript">
  <!--
  var isSubmitted = false;
  function login_onSubmit() {
  if (isSubmitted) {
  return false;
  } else {
  isSubmitted = true;
  return true;
  }
  }
  //-->
  </script>

This may relate to the
     onSubmit="return(login_onSubmit());"
ending of the ACTION line (see above), but if it does I probably do not
quite know what to make out of it.

I have tried to append
     &onSubmit=isSubmitted
to the end of my "-d" string (above), but it made no difference:
The target server confirmed I am logged in (as described above) but when I
call on my actual order page, it fails and downloads the login page again.

Can someone help me on this, please pretty please?

Thank you.
Randy

PS: I am quite sure the login IS persistent/cookie-controlled rather than
per-session, because I can close the browser (and even reboot the machine)
and I am still signed-in when I reopen the browser. But even with the
browser open and signed in, a cURL call from command line fails. This
behavior suggests to me my problem is in not sending back in the cURL call
the credentials the server is expecting.
Received on 2005-01-06