当前位置: > shell编程 >

shell脚本ping多台主机的代码

时间:2015-01-14 12:51来源:linux.it.net.cn 作者:IT
一段shell脚本,用于ping多台主机ip地址,命令行接收多个ip地址作为参数,将ping结果保存到文件host.txt中。


shell脚本连续ping多台主机: 
 

 

#!/bin/sh
#
#fileName:ping.sh
#

if test $# -eq 0
then
    echo "Please input IP!"
else
    for ipstr in $*
    do
        ping -c5 $ipstr >>Host.txt
        echo "" >> Host.txt
    done
fi

 

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容