Realm turned out to be model number of my router (default, changeable). So, after grabbing the realm, the modified version looks like:

#!/usr/bin/perl #use warnings; use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); $ua->credentials("192.168.0.103","DI-614+","admin","<OMITTED>"); my $response = $ua->get("http://192.168.0.1/st_devic.html"); die "Error while getting ", $response->request->uri, " -- ", $response->status_line, "\nAborting" unless $response->is_success; print $response->content, "\n";

Had to comment out the warnings because it wouldn't compile:

Can't locate warnings.pm in @INC (@INC contains: /usr/local/lib/perl5/ +site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 . / +usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503) at ip2.pl li +ne 3. BEGIN failed--compilation aborted at ip2.pl line 3.

I'm still getting the 401 error message with the code above. I've tried changing the first argument to be the router instead (192.168.0.1), with no luck. I know this can be done, for I can access the page through a web browser on the local net, and if I can do that, I should be able to have a script do the same, right?


In reply to Re: Re: Basic authentication with LWP::UserAgent by abeal
in thread Basic authentication with LWP::UserAgent by abeal

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.