in reply to Script to Notify of Public IP Change
Here is another alternative to retrieving your IP address.
I hate shelling out to an external command since I'd rather not assume that the command is there in the first place. A pure Perl way is more attractive to me.#!/usr/bin/perl -w ###################################################################### +## use strict; use LWP::UserAgent; # NOTE: make sure you mimic a browser with the agent name # whatismyip.com specifically returns a 403 error otherwise my $ua = LWP::UserAgent->new(agent=>"Mozilla/5.0"); my $response = $ua->get("http://automation.whatismyip.com/n09230945.as +p"); if ( $response->is_success ) { # this is how I caught the 403 orginal +ly printf "%s\n",$response->decoded_content; } else { printf "Bad Ju-Ju happened:\n\t%s\n",$response->status_line; } #comparison logic from here.
You can also look at this solution that I came up with for dealing with that issue by querying the administrative interface of my WRT54G router.
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Script to Notify of Public IP Change
by Arkevius (Initiate) on Nov 29, 2012 at 20:18 UTC |
In Section
Seekers of Perl Wisdom