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:

[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...]

Nice idea. I wanted it to work without temp files, as a one liner, and with only default Mac OS X apps (curl instead of lynx). I also use Ruby to strip the HTML. The result is below. (I use the TCSH shell, but modifying for Bash should be trivial.) I made an alias of the command and pass it the IP addr argument as variable \!:1. In .tcshrc you would define it as:

This script uses www.geoiptool.com to look up geolocation information for
IP numbers. You can suppress fields by removing them from the line
Host Name|IP Address|Country|Region|City|Postal|Calling|Longitude|Latitude
in Line 5 above.

I have named the command file geoloc. You can name it whatever. Syntax is

It should work on any standard Unix or Linux system with curl installed
as well as Mac OS X which includes curl in System 10.5. You will have to download
and install curl if you do not have it. You can find binaries for most systems at
http://curl.haxx.se/download.html
</snip>