批量ping域名获取ip

来源:互联网 发布:淘宝网上开店的流程 编辑:程序博客网 时间:2024/04/27 11:28

1、先把域名文件整理成每行一个域名的形式
2、在shell脚本里遍历域名文件每一行即每一个域名
3、通过 ping ${domain} -c 1|sed '1{s/[^(]*(//;s/).*//;q}' 语句截取ping结果获取域名解析ip

#!/bin/bashn=1for domain in `cat domains_arr.txt`do    ip=`ping ${domain} -c 1|sed '1{s/[^(]*(//;s/).*//;q}'`    echo -e $n "\t" $domain "\t" $ip    if [ "$ip" != "47.91.149.228" ]    then        echo -e $domain"\t"$ip >> chk_fail.txt    fi    n=$(($n+1))done
0 0
原创粉丝点击