Thanks. Your changes seemed to fix the immediate problem. I now get
Content is HTTP/1.0 302 (Found) Object moved Cache-Control: private Date: Fri, 01 Mar 2002 15:37:36 GMT Via: 1.1 Dyn-EH-NetCache (NetCache NetApp/5.1R2) Location: /index.asp Server: Greyware Web Server Content-Length: 131 Content-Type: text/html Client-Date: Fri, 01 Mar 2002 15:40:21 GMT Client-Peer: 208.14.208.55:80 Set-Cookie: ASPSESSIONIDGGQQGGAJ=KOMOONBBOOGGPDKDEEPCAAOI; path=/ Title: Object moved <head><title>Object moved</title></head> <body><h1>Object Moved</h1>This object may be found <a HREF="/index.as +p">here</a>.</body>
There is a good chance that with some tinkering I might be able to get this thing to work. One oddity is that the object moved message does not appear when I go to login.asp interactively and enter a password.

However, what I have now is a big improvement. I guess one lesson is to use

req->authorization_basic('jonathanmark', 'nottherealpassword');
instead of the credentials method.

Addendum: Finally got it to work. The trick turned out to be setting the referrer property so that the script seems to be coming from the page on which the form exists.

use HTTP::Request::Common qw(POST); use LWP::UserAgent; use HTTP::Cookies; use strict; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1)); for (my $i = 3543; $i < 4140; $i++) { # log in to authentication page. my $req = HTTP::Request->new(GET => 'http://www.sff.net/member/guestbo +okconfigurator.asp?jonathanmark'); $req->authorization_basic('jonathanmark', 'nottherealpassword'); my $content = $ua->request($req)->as_string; print "Login to configurator $i\n"; my $req = HTTP::Request->new(GET => 'http://www.sff.net/member/guestbo +ok.asp?jonathanmark'); $req->referer("http://www.sff.net/guestbookconfigurator.asp?jonathanma +rk"); $req->authorization_basic('jonathanmark', 'nottherealpassword'); my $content = $ua->request($req)->as_string; print "retrieved guestbook $i\n"; #delete an entry my $req = POST 'http://www.sff.net/guestbook.asp', Content => [ GuestbookName=>'jonathanmark', RecordID=>"$i", Button=>'Delete this Entry' ]; $req->referer("http://www.sff.net/guestbook.asp?jonathanmark"); $req->authorization_basic('jonathanmark', 'nottherealpassword'); my $content = $ua->request($req)->as_string; print "deleted $i\n"; }

In reply to Re: Re: Unable to get LWP Basic Authentication to Work by sierrathedog04
in thread Unable to get LWP Basic Authentication to Work by sierrathedog04

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.