ping.sh

#!bin/bash
#ping host  ip 
for hostip in {1..254};                
do
        ip="172.20.100.$hostip"
                ping -c 1 -W 2 $ip &> /dev/null 
        if [ "$?" == "0" ];then
                echo $ip is UP
                echo -e "ip:$ip up" | tee -a up.txt
        else
                echo $ip is DOWN
                echo -e "ip:$ip down" | tee -a down.txt
        fi
done
posted @ 2019-01-15 10:27  舍&得  阅读(297)  评论(0编辑  收藏  举报