內網羣PING的shell

#!/bin/bash
ips=192.168.0
echo -n "請輸入 network 網段(缺省爲$ips): "
read network
: ${network:=$ips}
echo "network:$network"
   d_ip_beg=1
   d_ip_end=254
   echo -n "input the hostip(default $d_ip_beg $d_ip_end):"
read ip_beg ip_end
: ${ip_beg:=$d_ip_beg}
: ${ip_end:=$d_ip_end}
 echo "ip_beg:$ip_beg"
 echo "ip_end:$ip_end"

for ((i=$ip_beg;i<=$ip_end;i++)); do
    host=$network.$i
    ping -W 1 -c 1 $host  &>/dev/null && echo "$host is up" |tee -a uplog || echo "$host is down"
done
   echo "欲知存活的主機列表,請查看UPLOG日誌文件"


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章