pingnet.sh
时间:2010-12-31 来源:xyqcuijia
1 #!/bin/bash
2 #Description:
3 #Date:
4 #Author: Cui
5 #Version: 0.01
6
7 cping() {
8 PINGNET=`echo $1 | sed 's/\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/g'`
9
10 let I=1
11 while [ $I -le 255 ]; do
12 ping -c1 -W1 $PINGNET.$I &> /dev/null
13 [ $? -eq 0 ] && echo "$PINGNET.$I online." || echo "$PINGNET.$I offline."
14 let I++
15 done
16 }
17
18 bping() {
19 BPINGNET=`echo $1 | sed 's/\([0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/g'`
20 let M=0
21 while [ $M -le 254 ]; do
22 cping $BPINGNET.$M
23 let M++
24 done
25 }
26
27 read -p "Input a network:" MYNET
28 bping $MYNET
相关阅读 更多 +