[Memphis.pm] getting an ip address from a router/device with webpage config
Alaric Ravenhall
alaricravenhall at hotmail.com
Tue Nov 13 18:03:57 CST 2001
Hrm. Here's a way.
Assuming your WAN IP starts with 24.24. Also assuming it needs no
username/password combo, for which you'd use UA's get_basic_credentials() in
some fashion.
This script could be further extended to email the ip address somewhere, or
input it through a webpage interface. If you are inputting into a webpage,
you could trim out the file I/O and just make a tidy log file at the end of
the script.
I wrote this off the cuff, haven't had time to sit down and test it AT ALL,
so expect bugs.
Ravenhall
--------------------------------------------------
#!/usr/bin/perl
use beer;
Begin script:
---------------
#!/usr/bin/perl -w
require LWP::UserAgent;
my $ua = LWP::UserAgent->new(env_proxy => 1,
keep_alive => 1,
timeout => 30,);
my $response = $ua->get('http://router-ip-address-here/');
my $old = "/tmp/myip";
my $new = "/tmp/oldip";
rename($old, $new) or die "can't mv $old to $new !!";
open(FH, "+> /tmp/myip") or die "Can't open new file /tmp/myip!";
while (<FH>) {
$response =~ \24.24.[1-255].[1-255]\;
(print FH $_) or die "can't write to $new: $!";
}
close(FH) or die "Can't close the file!";
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------
More information about the Memphis-pm
mailing list