LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 02-15-2007, 10:47 AM   #1
Travesser
LQ Newbie
 
Registered: Feb 2006
Posts: 2

Rep: Reputation: 0
cURL not posting login data?


Hello,

I have searched much for the answer to this question; most of my Google
searches bring up the same thing, the cURL manual. Done much experimentation
but to no avail.

I am running an automated script that compares content of a web page against the last
time it was checked (using diff) to see if it was updated. Works great.

Now I want to check a page (php bulletin board) which requires logging in
with password.

According to the cURL manual, this should be no big deal. Quote from the cURL
manual:

"It's easy to post data using curl."

The "form" container of the page looks like this:

<form action="login.php" method="post" target="_top">
<input type="text" name="username" size="25" maxlength="40" value="" /></div>
<input type="password" name="password" size="25" maxlength="32" /></div>
<input type="checkbox" name="autologin" />
<input type="hidden" name="redirect" value="viewforum.php?f=1&start=0" />
<input type="submit" name="login" class="mainoption" value="Log in" /><br />
</form>

Following the directions from the POST (HTTP) section of the manual I enter this:

(NOTE: the URL I have used in each case was entered as a full http protocol URL when
running the command. I have removed the http protocol prefixes here to keep them from being parsed as a link.)

curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0

The URL supplied is the URL which, if I am logged out using a particular browser,
this would take me to a login page, and then once the login data was entered and
submitted, would normally take me right to the desired forum page.

I am assuming then, that by posting the data using cURL as I have done, it should
download the content of that same desired forum page.

Instead, the output I get is something like this:

allasso:~ allasso$curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0
[1] 863
[2] 864

THEN, if I keep re-entering the same command, it looks like this (notice the numbers
in brackets seem to increase sequentially):

allasso:~ allasso$curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0
[3] 865
[4] 866
[1] Done curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php
[2] Done f=1
allasso:~ allasso$curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0
[5] 867
[6] 868
[3] Done curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com.com/login.php?redirect=viewforum.php
[4] Done f=1

As I said, I just simply want it to download the same page that shows up when I submit
data manually from a browser.

I then tried entering the same information using the -F option instead of -d:

curl -F "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0

This gives me similar output, only this time it will download the login page (not the page I
wish to be directed to), and then does not exit.

If I simply press return again, I get this:

[1]- Done curl -F "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com.com/login.php?redirect=viewforum.php
[2]+ Done f=1

Anyone know what is going on, and what I need to do to get cURL to get past the login
page and download the desired page each time?

Thanks,

Allasso
 
Old 02-15-2007, 01:14 PM   #2
Travesser
LQ Newbie
 
Registered: Feb 2006
Posts: 2

Original Poster
Rep: Reputation: 0
my apologies for the incorrect use of "cURL".

It should be "curl"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cURL ballistic509 Debian 2 06-11-2006 01:06 PM
Website member login and data retrieval lord-fu Programming 3 03-13-2006 02:27 PM
Using Curl command backpackingbiker Ubuntu 1 06-21-2005 04:16 PM
PHP/cURL housemusic42 Linux - Networking 0 10-07-2004 02:45 PM
curl mod HELP! name taken Linux - Software 0 09-29-2003 07:53 PM


All times are GMT -5. The time now is 08:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration