LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > 脚本编程 >

查询IP地址归属地shell脚本

时间:2012-04-26 10:35来源:linuxso 编辑:admin 点击:
#!/bin/bashipp (){exec $1while read adosring=`curl -s http://ip138.com/ips138.asp?ip=${a}action=2 |grep ul class=ul1li |awk -F[]+ {print $5}`echo $a $sringdone}case $1 in-f) shift ipp $1;;-i) shift sring=`curl -s http://ip138.com/ips138.asp
#!/bin/bash
ipp (){
exec < $1
while read a
do
sring=`curl -s  "http://ip138.com/ips138.asp?ip=${a}&action=2" |grep '<ul class="ul1"><li>' |awk -F'[><]+' '{
print $5}'`
echo $a $sring
done
}
case $1 in
-f)
        shift
        ipp $1
;;
-i)
        shift
        sring=`curl -s  "http://ip138.com/ips138.asp?ip=${1}&action=2" |grep '<ul class="ul1"><li>' |awk -F'[
><]+' '{print $5}'`
        echo $1 $sring
;;
*)
        echo "[Help]
        $0 need -f or -i
        -f ------- argument is a file
        -i ------- argument is a IP
[For example]:
        $0 -f filename
        $0 -i ipadress
        "
;;
esac

转载请保留固定链接: https://linuxeye.com/program/397.html

------分隔线----------------------------
标签:脚本IP归属地
栏目列表
推荐内容