首页 > 系统服务 > 详细

查询ip归属地的shell脚本

时间:2015-02-26 16:47:13      阅读:197      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
ipp(){
exec < $1
while read a
do
string1=`curl -s "http://www.ip138.com/ips138.asp?ip=${a}&action=2"|iconv -f gb2312 -t utf-8|grep ‘<ul class="ul1"><li>‘ | awk -F ‘[<>]+‘ ‘{print substr($5,7)}‘`
echo $a
echo -e "\033[44;37;5m $string1 \033[0m"
done
}
case $1 in
-f)
shift
ipp $1
;;
-i)
shift
string1=`curl -s "http://www.ip138.com/ips138.asp?ip=${1}&action=2"| iconv -f gb2312 -t utf-8 |grep ‘<ul class="ul1"><li>‘ | awk -F ‘[<>]+‘    ‘{print substr($5,7)}‘`
echo $1
echo -e "\033[44;37;5m $string1 \033[0m"
;;
*)
echo "[Help]
$0 need -f or -i
-f ------ argument is a file
-i ------ argument is a IP
[For example]:
$0 -f filename
$0 -f ipaddress
"
;;
esac


本文出自 “linux_cheng” 博客,请务必保留此出处http://6764097.blog.51cto.com/6754097/1615434

查询ip归属地的shell脚本

原文:http://6764097.blog.51cto.com/6754097/1615434

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!