shell 批量检测网络地址
#!/bin/bash
#create by linhexiao 2016-04-16
#mail:huangdengji@126.com
#V1.0
file="$1"
log="$2"
while read line
do
echo "$line">>${log}
arr=(${line//\t/ })
ip=${arr[4]};
if [ "${#ip}" -ne 0 -a "$ip" != "支队机房不通IP" ];then
# echo "$line";
ping -c 4 "$ip">>${log}
echo -e "\n\n "
fi
done<"$file"
echo "ping ${file} ok ,write log to ${log}"
exit 1
file模板
001 卡口 卡口像机 南 192.168.99.1 像机
001 卡口 卡口存储 南 192.168.99.2 存储
001 卡口 卡口像机 南 192.168.99.3 像机
命令执行
pings.sh text1.txt log1.log