Evening all,

I've been scouring the net for an answer on this, but I'm getting no love whatsoever. I'm trying to grab the DHCP WAN address of the moment from my router for publishing on a website. I've run across several scripts so far, but none have worked as of yet. Let me post what I have so far...(disclaimer: I am not new to programming, but I am new to Perl)

#!/usr/bin/perl # Dynamic DNS determining program # # Usage: Ask the router for the WAN address, and post it to # the webp +age. # # require LWP::UserAgent; $in_file = "./WANIP_LOG.txt"; $out_file = "./WANIP_LOG.txt"; $dlinkpwd = '<OMITTED>'; $ua = LWP::UserAgent->new; $ua->credentials('192.168.0.103','192.168.0.103','admin',$dlinkpwd); $req = HTTP::Request->new('GET','http://192.168.0.1/st_devic.html'); $res = $ua->request($req); print $res->status_line; print "\n";

Now, 192.168.0.1 is my router, 192.168.0.103 is the machine the script will be executed from, and st_devic.html is the page I access to retrieve the IP when I'm working through a browser. I keep getting 401 - Unauthorized returned as a status code. Have I missed something? I'll admit, I'm a bit iffy on the realm thing...
Any help would be very much appreciated.
~Aron

20031112 Edit by jeffa: Changed title from 'LWP::UserAgent'


In reply to 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.