#!/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日志文件"