#!/bin/bash # Christopher Jones # 08/09/2013 # ipcountry.sh # finds country of ip #Input Argument IPADDR="$1" #Make Temp File STOR=$(mktemp /tmp/locationscraper.tmp.XXXXXXXXX) #Download html data and filter curl "http://viewdns.info/iplocation/?ip=$IPADDR" --retry 2 --retry-delay 3 --connect-timeout 3 --no-keepalive\ -s -e "http://www.proxys.com.ar/" -A 'proxb0t' 2> /dev/null | grep "Country Code:" | sed 's/
/\n/g;s/ //g;s/:/\n/g' |\ grep -i -A1 "countrycode" | grep -vi "countrycode">> $STOR COUNTRY=$(cat "$STOR") echo "$COUNTRY" #Remove temp file rm -rf "$STOR"