多学点东西,再写写自己的收获,和大家共分享。 这样对linux都有贡献。。。。

发布新日志

  • bash-得到IP地址对应的地理信息

    2008-08-02 20:44:46

    好久好久没写日志了,蛮贴一个脚本:得到IP地址对应的地理信息

    如:
      ./sip  222.73.99.99
        ip: 222.73.99.99
        本站主数据:上海市 电信
        参考数据一:上海市 电信
        参考数据二:上海市 电信ADSL



    保存以下脚本为: sip


    #!/bin/bash
    if (($# != 1  )); then
        echo "need ip!"
        exit
    fi
    ip=$1
    echo  " ip: $ip"
    curl   -s "http://www.ip138.com/ips.asp?ip=$ip&value=2"  \
              |grep "ul1" | grep  class | iconv -f gb2312 -t utf-8  \
              |  sed -e 's/^.*"><li>/\t/' -e  's/<\/li><li>/\n\t/g' -e 's/<.*$//'

Open Toolbar