Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'find out your IP address from whatismyip.com' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
find out your IP address from whatismyip.com
Authored by: hayne on Jun 12, '03 02:29:57PM
There are a few web sites that can be used for finding out your (external) IP address. One of them is www.whatismyip.com Of course it is better to obtain this info from your router if you can (as in the script used in the hint) but if you can't get such a script to work, here is a Perl script that gets the IP address from the HTML page that is returned by www.whatismyip.com
#!/usr/bin/perl
my $url = "http://www.whatismyip.com/";
my $html = `/usr/bin/curl -s -f  $url`;
if ($html =~ /Your ip is (\d+\.\d+\.\d+\.\d+)/i) 
{
    my $ipaddr = $1;
    print $ipaddr;
    print "\n"; # remove this line if newline at end not wanted
    exit;
}
print STDERR "Failed to get IP address from $url\n";
exit;


[ Reply to This | # ]
backslashes missing
Authored by: hayne on Jun 12, '03 02:34:40PM

It's really frustrating to enter code in these comments since the Preview lies through it's teeth about what will be shown.
In the above script that I posted, there are missing backslashes in several places:
- before each of the 4 d's in the pattern
- before the n's in two of the print statements



[ Reply to This | # ]
Use the special tags...
Authored by: robg on Jun 13, '03 08:24:44AM
Set the mode to html and then write your code like this:
[code]
some <examples> of code \ and \ backslashes
[/code]
Then when you hit publish, everything will be retained. This will not work if you use "pre" or "tt" tags! And yes, they are SQUARE brackets around "code," not angle brackets. I need to add the instructions to the comment posting page; they are already on the story posting page...

-rob.

[ Reply to This | # ]