From time to time I like to know (when reviewing log files) where an IP address is geographically located. The following shell script will take a list of IP address in a file named list, and look up their geographic location. Here's the code:
#!/bin/bash echo "Put the IPs you want to lookup into a file named list." url="http://www.geoiptool.com/en/?IP=" for i in `cat list` do lynx -dump $url$i > tmp cat tmp | sed -n '/Host Name/,/Postal code/p' rm tmp done
jamesk@HOME~/Desktop $ echo 198.6.1.5 > list jamesk@HOME~/Desktop $ geo Put the IPs you want to lookup into a file named list. Host Name: cache04.ns.uu.net IP Address: 198.6.1.5 Country: [14]United States united states Country code: US (USA) Region: [15]Oregon City: Eugene Postal code:[robg adds: Note that this hint requires the lynx text-only web browser, which you can install via Fink or MacPorts or probably many other methods. I'm sure there's probably a way to do this without lynx, but I'll leave that to those who actually know what they're doing...]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20100109053441706