Support Forums

Full Version: Getting your external ip with perl
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
You can get your external ip with perl by running this script...however, you have to install the LWP::Simple first. If you are on mac or linux you can simply go to the command line and type:
sudo cpan
You may have to set up cpan, for the most part you use all defaults, and choose servers near you.
then run
install LWP::Simple
cpan may ask you some more questions, just agree.

Then you can run this:

PHP Code:
#!/usr/bin/perl
use LWP::Simple;
$whyip qr/(Your IP address is \d+\.\d+\.\d+.\d+)/;
$content get("http://whatismyipaddress.com");
if(
$content =~ $whyip){
 print $&;


If you don't know your path to perl(#!/usr/bin/perl) then run it by typing
perl nameofscript.pl
It's simple, thanks anyway. Smile
Nice. I can use this for my bot Smile.
But won't you need to backslash those dots and "d's"?
Edit: I've noticed this is not working, because of the useragent. It says: "it appears to be an automated script".
Simple and nice Smile thanks for sharing this code...
Thank's for the share man Oui
Simple but useful, thanks.
and if you find a better website to get your IP address from then you can change the url in there (obviously) lol. I've noticed a few of these IP getting perl codes interpretted by others. It seems to be a popular area in this perl forum.
Thanks alot for sharing this with us man.
(09-26-2010, 12:29 AM)Infinity Wrote: [ -> ]and if you find a better website to get your IP address from then you can change the url in there (obviously) lol. I've noticed a few of these IP getting perl codes interpretted by others. It seems to be a popular area in this perl forum.

Should you change the URI you would need to adjust the RegEx pattern to match. The pattern Bsdpunk created is specific to the site he has set by default.
good work thanks for sharing
Pages: 1 2