azaidi has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I have a server which serves up a page with two textboxes. One for the username and the other for the passwd.

I want to automate logins and fetch the usernames and passwds from a database using a UID set in a cookie.

Once I've done that I'll have to connect to the server, 'fill out' the two boxes and then POST the info to the server...

How do I do that, prefferably using CGI.pm. It's the posting part that's got me really confused...

Thanks in advance

Replies are listed 'Best First'.
RE: How do I POST info to a server?
by snowcrash (Friar) on Apr 08, 2000 at 23:39 UTC
    If I understand your question right, CGI.pm is definitly not the right thing for something like that. Check out the LWP (libwww-perl) man page.

    I think you want to do something like this:
    #!/usr/bin/perl -w use LWP; print "Content-type:text/html\n\n"; $url = "http://www.blabla.com/cgi-bin/foobar.pl"; $ua = new LWP::UserAgent; my $req = new HTTP::Request POST => $url; $req->content_type('application/x-www-form-urlencoded'); $req->content('username=snowcrash&passwd=123456'); my $res = $ua->request($req); print $res->content;
RE: How do I POST info to a server?
by chromatic (Archbishop) on Apr 08, 2000 at 23:10 UTC
    CGI.pm is not appropriate in this case, as it is designed to run on the server side. In your example, you need something designed to work as a client.

    Have a look at the LWP bundle -- especially LWP::UserAgent. It contains a credentials() method which will allow you to set a username and password.