read -p "Please input a network address:" IP
let NET=`echo $IP | cut -d'.' -f3`
if [ $NET -le 254 -a $NET -ge 0 ]
then
for I in {1..254}
do
trap 'trap 2' SIGINT SIGTERM
echo "Now is ping 192.168.$NET.$I..."
ping -c 3 -t 2 192.168.$NET.$I &> /dev/null
if [ $? -eq 0 ]
then
echo -e "\033[32mThe host of 192.168.$NET.$I is on line\033[0m"
else
echo -e "\033[33mThe host of 192.168.$NET.$I is off line\033[0m"
fi
done
else
echo "Input Error,Exit!"
fi
阅读(593) | 评论(0) | 转发(0) |