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


Click here to return to the 'Geolocate a number of IP addresses via shell script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Geolocate a number of IP addresses via shell script
Authored by: ctierney on Jan 13, '10 10:09:20AM
Thanks for the hint. I look forward to including this in my work flow! Here's a version that reads from stdin, fetches with curl, and parses with awk:
#!/bin/sh
while read ip; do
    curl -s 'http://www.geoiptool.com/en/?IP='$ip | \
    awk -F '(</?[^>]+>)+' '/Host Name/,/Postal code/ {
        if (/:/) {printf("%13s ", $2); getline; print $2}
    } END {print}'
done


[ Reply to This | # ]
Geolocate a number of IP addresses via shell script
Authored by: tobylane on Jan 14, '10 08:05:57AM

It just hangs me for, for three minutes before I stopped it.



[ Reply to This | # ]
Geolocate a number of IP addresses via shell script
Authored by: ctierney on Jan 14, '10 08:28:28AM
It's reading from stdin, so it will appear to hang if you don't feed it any ip numbers. I named mine ip2geo:
echo 198.6.1.5 | ip2geo


[ Reply to This | # ]