shell编程 测试单个主机或网段主机存活(2)

do
                        if ping -c 1 -W 1 ${Test1}$i &> /dev/null ;then
                                echo "Have ${Test1}$i"
                                Num=$((Num+1))
                        else
                                Fail=$((Fail+1))
                                echo "No ${Test1}$i"
                fi
        done
        echo "Host online have $Num ." 
        echo "Host no online have $Fail ."

最后一个for循环,我嫌多,只写了10个值,有兴趣的哥们,自己改 seq 1 10改成1 254即可...还有关于a类b类c类网,由于本人网络方面知识的欠缺,所以判断的值,估计挺不正确的,列位就谅解一下吧....

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/83beec93149dc81225c075a1e4d643e2.html