SHARE
TWEET

geoip

a guest May 22nd, 2016 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/bash
  2. ip_lookup="$*"
  3. url="http://geoiplookup.net/ip"
  4. prog=`basename $0`
  5. usage="USAGE:  $prog IP IP2 .... IPn"
  6. if echo "${ip_lookup}" | grep -E '[ \t]*[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[ \t]*' > /dev/null 2>&1 ;then
  7.    :
  8. else
  9.    echo "$usage" >&2
  10.    exit 5
  11. fi
  12.  
  13. for i in `echo $ip_lookup`
  14.    do
  15.      _info=`curl -s "$url/$i" | sed -n '/IP Address:/{n;p};/Country:/{n;p};/City:/{n;p}'`
  16.  
  17.     echo "${_info}" | sed 's/<[^>]*>//g'
  18.     echo
  19. done
  20. exit 0
RAW Paste Data
Top