vi
ipaddresses
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
192.168.1.7
#!/bin/bash
#reading data from a file
count=1
cat ipaddresses | while read line
do
echo "Line $count: $line"
ip=`echo "$line" | awk -F# '{print $1}'`
ping -c 2 -W 1 $ip &> /dev/null
if [ "$?" == "0" ];then
echo $line is UP
echo $line is UP >> /root/ipup.txt
#break;
else
echo $line is DOWN
echo $line is DOWN >> /root/ipdown.txt
fi
count=$[ $count + 1 ]
done
echo finished processing the file
阅读(1858) | 评论(0) | 转发(0) |