歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> SHELL編程 >> 檢車主機是否暢通,ping shell

檢車主機是否暢通,ping shell

日期:2017/3/1 14:01:48   编辑:SHELL編程
檢車主機是否暢通,ping shell #!/bin/bash #2013-10-21 # ping檢測網絡是否暢通 set -u #set -x ping_fun(){ d_network=192.168.1 echo -n "input the network(default $d_network):" read network : ${network:=$d_network} echo "network:$network" d_hostip_beg=1 d_hostip_end=254 echo -n "input the hostip(default $d_hostip_beg $d_hostip_end):" read hostip_beg hostip_end : ${hostip_beg:=$d_hostip_beg} : ${hostip_end:=$d_hostip_end} echo "hostip_beg:$hostip_beg" echo "hostip_end:$hostip_end" count=1 up_host='正常IP:'; for ((hostip=$hostip_beg;hostip<=$hostip_end;hostip++)); do host=$network.$hostip echo "開始ping檢測$host" ping -c $count $host &>/dev/null if [ $? = 0 ];then echo "IP $host 是正常的" up_host="$up_host $host" else echo "IP $host 是不正常的" fi done echo $up_host; exit 0 } echo "----開始執行ping程序----" ping_fun
Copyright © Linux教程網 All Rights Reserved