标签:style blog ar color os sp for on div
最近在学习shell 编程,闲来无事,搞了一个小shell. 可以用来 对一个网段的存活主机进行 探测。
1 #!/bin/bash 2 # 3 #date:2014/12/18 4 #blog:www.cnblogs.com/outline 5 #by :Joe 6 7 if [ $# -lt 1 ] ; then 8 echo " err, usage: ping.sh ARg " 9 echo " eg : ping.sh 192.168.1" 10 exit 8 11 fi 12 13 ips="$1" 14 stat=1 15 for ip in $(seq 1 254) 16 do 17 ping -c 1 ${ips}.${ip} >/dev/null && stat=1 || stat=0 18 if [ $stat -eq 1 ];then 19 echo " $ips.$ip is up" 20 21 fi 22 done 23 24 if [ $stat -eq 1 ]; then 25 echo " no host up" 26 fi
.
标签:style blog ar color os sp for on div
原文地址:http://www.cnblogs.com/outline/p/4171973.html