Linux shell ping 指定ip段

787阅读 1评论2011-10-02 niao5929
分类:

#! /bin/bash
for a in {1..254} #不行就改成$(seq 1 254)或者for(())
do
if -w 1 -c 1 192.168.1.$a | grep "100%" >/dev/null  #一次变量的ip地址 (c1)ping一次 由于ping 的等待时间长 所以我定义了 参数 –w –l 表示等待超时的时间为1秒,

 

then


echo "192.168.1.$a is Not reachable"


else


echo "192.168.1.$a is reachable"


fi


done



上一篇:蚂蚁带来的启示
下一篇:python学习的好东西!

文章评论