代码:
[root@test sh]# cat ping.sh
#!/bin/bash
for START in (seq024)doIP=\”192.168.1.(seq 0 24)doIP=\”192.168.1.(seq024)doIP=\”192.168.1.START\”
ping -c 3 -i 0.2 -W 3 $IP &> /dev/null
if [ $? -eq 0 ]
then
echo “Host $IP is Online.”
echo $IP >>/tmp/up.txt
else
echo “Host $IP is Offline.”
echo $IP >>/tmp/down.txt
fi
let START++
done