Hear us Roar
Article:
 |
|
Scripting Dot Mac
|
| Subject: |
|
Another way to get your IP address |
| Date: |
|
2005-03-19 07:34:31 |
| From: |
|
ptwobrussell
|
|
|
|
I've had some readers express difficulty in getting their IP address that the web sees (their "external" IP address--not necessarily the one given with "ifconfig"), so I whipped up a little script that you can use to get it another way if you're having trouble.
Save the script to a file and make it executable with "chmod u+x"
#!/bin/bash
####################################################
#Matthew Russell - 19 Mar 05
#
#A way to get your IP address (external to the web)
#from a courtesy web site
####################################################
#a page containing your ip address
wget -q "http://whatismyip.com/index.html"
#scrape out the actual ip address from its title line:
#<title>Your ip is 123.456.789.012 WhatIsMyIP.com</title>
#all one line
perl -n -e 'if (m#(<title>Your ip is )([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)( WhatIsMyIP\.com)#) {print "$2\n";}' index.html > /tmp/ipAddress
Hope that helps.
M.
|
|
| |