I overhauled blue_cowdawg's solution and came up with this, which works for my Windows + Netgear router. If you run Linux, you need to parse the output of 'ifconfig', instead of 'ipconfig'.

Parsing the output of the Asante should be similar too.

#!/usr/bin/perl -w ###################################################################### +## # Get External IP address of Netgear router ################################################# use strict; use warnings; use LWP::UserAgent; use Data::Dumper; #use HTML::TableContentParser; use Getopt::Long; my $host=""; my $user=""; my $password=""; my $addr = ""; my $port=80; my $Netgear_Page = "s_status.htm"; # Netgear Router status my $Linksys_Page = "Status_Router.asp"; my $result=GetOptions( "host=s" => \$host, "user=s" => \$user, "password=s" => \$password, "ipaddress=s" => \$addr, "port=i" => \$port ); my $ua=LWP::UserAgent -> new(); if ($host){ }else{ for (qx/ipconfig/){ m/^\s+Default Gateway\D+([\d|\.]+)/ and $host=$1 }; } barf_and_complain() unless ( $host and $user and $password ); my $host_settings=sprintf("%s:%d",$host,$port); my $url = sprintf("http://%s:%d/$Netgear_Page",$host,$port); my $req = HTTP::Request->new(GET => $url); $req->authorization_basic($user, $password); my $content = $ua->request($req)->as_string; ##print "----Content--\n$content-----\n"; while ($content=~m/<table.*?>(.+?)<\/table>/igs){ my $table = $1; ##print "----TABLE:$table\n\n"; $table =~m/<h\d>(.+?)<\/h\d>/igs and print "=====TABLEHEAD: $1\n"; for ("MAC Address", "IP Address", "Domain Name Server"){ $table =~m/<td.*?>$_.+?<\/td>\s*<td.*?>([\w|:|\.|<|>]+?)<\/td>/ and print "\t $_ $1\n"; } } sub barf_and_complain { printf "%s\n",qq( You must specify all options for this plugin to work: --host hostname or ip of router --user security user of router --ipaddress expected ip address --password login password for router the --port option is just that, an option and default +s to 80 ); exit(1); }
Modifications made :

     "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken


In reply to Re: Get IP address from my Asante Cable/DSL router by NetWallah
in thread Get IP address from my Asante Cable/DSL router by Plankton

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.