shell通过ping实现ip检测教程
#!/bin/bash
for i in `seq 2 254`
do
ping -w 1 $1.$i > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "The server(${i}) status is UP"
echo $1.$i >> ip.txt
else
echo "The server(${i}) status is DOWN"
fi
done
执行:
./xx.sh 192.168.10
-w 1指定超时时间为1秒