Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Script to Notify of Public IP Change

by blue_cowdawg (Monsignor)
on Nov 29, 2012 at 18:47 UTC ( #1006327=note: print w/ replies, xml ) Need Help??


in reply to Script to Notify of Public IP Change

Here is another alternative to retrieving your IP address.

#!/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.
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.

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


Comment on Re: Script to Notify of Public IP Change
Download Code
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
    That is indeed a nice bit of code there. Thanks for the share.

    I was also looking at querying the router they have, and actually tried a bit of code, but ran into an access problem. So, I just gave up and went the simpler way. I'll definitely have to read your solution a bit more in full later when I have the time.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2015-07-29 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls