weblog d’un abbe

20070501

WhatIsMyIP – a perl hack

Filed under: Hacking — abbe @ 2020

The script below will print the real IP address of the internet connection used:

#!/usr/bin/perl -w
#whatismyip.pl - This script uses http://www.whatismyip.com/ service.

use LWP::Simple;
use strict;

my $url = "http://www.whatismyip.com/";

my $content = get($url);
$content =~ s/.*<TITLE>WhatIsMyIP.com - (\d{1,3}?.\d{1,3}?.\d{1,3}?.\d{1,3}?)<\/TITLE>.*/$1/sig ;
print $content;

So, now I can DynDNS from my box instead of my ADSL modem :)

Advertisements

1 Comment »

  1. Great hack, but the guys and whatismyip.com made things a bit easier and provided a page that doesn’t need to be cleaned with a regex:

    #!/usr/bin/perl -w
    #whatismyip.pl – This script uses http://www.whatismyip.com/ service.

    use LWP::Simple;
    use strict;

    my $url = “http://www.whatismyip.com/automation/n09230945.asp”;

    my $content = get($url);
    print “$content\n”;

    Comment by scyon — 20080713 @ 0622


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: