以下是引用madfrogme在2012-8-19 16:28:56的发言:
我已经把-n 该成-c
把-w 该成-W了,
--
如果你ping得地址是没错的话 应该是没问题的啊我已经把-n 该成-c
把-w 该成-W了,
--
linux下跑这个挺快的嘛
程序代码:
#!/bin/bash STEP=32 IP=127.0.0. for ((i=1;i<256;i=i+STEP)) do echo ping $IP$i for ((j=i;j<i+STEP&&j<256;j++)) do ping $IP$j -c 1 -W 1 > $j.txt & done # sleep 1 done cat /dev/null > result.txt for ((i=1;i<256;i++)) do cat $i.txt >> result.txt done
[root@kel tmp]# cat result.txt
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_req=1 ttl=64 time=0.077 ms
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.077/0.077/0.077/0.000 ms
PING 127.0.0.2 (127.0.0.2) 56(84) bytes of data.
64 bytes from 127.0.0.2: icmp_req=1 ttl=64 time=0.029 ms
--- 127.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.029/0.029/0.029/0.000 ms
PING 127.0.0.3 (127.0.0.3) 56(84) bytes of data.
64 bytes from 127.0.0.3: icmp_req=1 ttl=64 time=0.053 ms
--- 127.0.0.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.053/0.053/0.053/0.000 ms
PING 127.0.0.4 (127.0.0.4) 56(84) bytes of data.
64 bytes from 127.0.0.4: icmp_req=1 ttl=64 time=0.030 ms
--- 127.0.0.4 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.030/0.030/0.030/0.000 ms
PING 127.0.0.5 (127.0.0.5) 56(84) bytes of data.
64 bytes from 127.0.0.5: icmp_req=1 ttl=64 time=0.029 ms
--- 127.0.0.5 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.029/0.029/0.029/0.000 ms
PING 127.0.0.6 (127.0.0.6) 56(84) bytes of data.
64 bytes from 127.0.0.6: icmp_req=1 ttl=64 time=0.032 ms
--- 127.0.0.6 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.032/0.032/0.032/0.000 ms
PING 127.0.0.7 (127.0.0.7) 56(84) bytes of data.
64 bytes from 127.0.0.7: icmp_req=1 ttl=64 time=0.050 ms
--- 127.0.0.7 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms
PING 127.0.0.8 (127.0.0.8) 56(84) bytes of data.
64 bytes from 127.0.0.8: icmp_req=1 ttl=64 time=0.041 ms
--- 127.0.0.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.041/0.041/0.041/0.000 ms
PING 127.0.0.9 (127.0.0.9) 56(84) bytes of data.
64 bytes from 127.0.0.9: icmp_req=1 ttl=64 time=0.034 ms
--- 127.0.0.9 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.034/0.034/0.034/0.000 ms
PING 127.0.0.10 (127.0.0.10) 56(84) bytes of data.
64 bytes from 127.0.0.10: icmp_req=1 ttl=64 time=0.027 ms
--- 127.0.0.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.027/0.027/0.027/0.000 ms
PING 127.0.0.11 (127.0.0.11) 56(84) bytes of data.
64 bytes from 127.0.0.11: icmp_req=1 ttl=64 time=0.026 ms
--- 127.0.0.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.026/0.026/0.026/0.000 ms
PING 127.0.0.12 (127.0.0.12) 56(84) bytes of data.
64 bytes from 127.0.0.12: icmp_req=1 ttl=64 time=0.056 ms
--- 127.0.0.12 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.056/0.056/0.056/0.000 ms
PING 127.0.0.13 (127.0.0.13) 56(84) bytes of data.
64 bytes from 127.0.0.13: icmp_req=1 ttl=64 time=0.027 ms
--- 127.0.0.13 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.027/0.027/0.027/0.000 ms
PING 127.0.0.14 (127.0.0.14) 56(84) bytes of data.
64 bytes from 127.0.0.14: icmp_req=1 ttl=64 time=0.030 ms
--- 127.0.0.14 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.030/0.030/0.030/0.000 ms
PING 127.0.0.15 (127.0.0.15) 56(84) bytes of data.
64 bytes from 127.0.0.15: icmp_req=1 ttl=64 time=0.026 ms
--- 127.0.0.15 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.026/0.026/0.026/0.000 ms
PING 127.0.0.16 (127.0.0.16) 56(84) bytes of data.
64 bytes from 127.0.0.16: icmp_req=1 ttl=64 time=0.047 ms
--- 127.0.0.16 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.047/0.047/0.047/0.000 ms
PING 127.0.0.17 (127.0.0.17) 56(84) bytes of data.
64 bytes from 127.0.0.17: icmp_req=1 ttl=64 time=0.033 ms
--- 127.0.0.17 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.033/0.033/0.033/0.000 ms
PING 127.0.0.18 (127.0.0.18) 56(84) bytes of data.
64 bytes from 127.0.0.18: icmp_req=1 ttl=64 time=0.025 ms
--- 127.0.0.18 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.025/0.025/0.025/0.000 ms
PING 127.0.0.19 (127.0.0.19) 56(84) bytes of data.
64 bytes from 127.0.0.19: icmp_req=1 ttl=64 time=0.033 ms
--- 127.0.0.19 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.033/0.033/0.033/0.000 ms
PING 127.0.0.20 (127.0.0.20) 56(84) bytes of data.
64 bytes from 127.0.0.20: icmp_req=1 ttl=64 time=0.026 ms
--- 127.0.0.20 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.026/0.026/0.026/0.000 ms
PING 127.0.0.21 (127.0.0.21) 56(84) bytes of data.
64 bytes from 127.0.0.21: icmp_req=1 ttl=64 time=0.027 ms
--- 127.0.0.21 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.027/0.027/0.027/0.000 ms
PING 127.0.0.22 (127.0.0.22) 56(84) bytes of data.
64 bytes from 127.0.0.22: icmp_req=1 ttl=64 time=0.026 ms
--- 127.0.0.22 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.026/0.026/0.026/0.000 ms
PING 127.0.0.23 (127.0.0.23) 56(84) bytes of data.
64 bytes from 127.0.0.23: icmp_req=1 ttl=64 time=0.027 ms
--- 127.0.0.23 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.027/0.027/0.027/0.000 ms
PING 127.0.0.24 (127.0.0.24) 56(84) bytes of data.
64 bytes from 127.0.0.24: icmp_req=1 ttl=64 time=0.060 ms
--- 127.0.0.24 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.060/0.060/0.060/0.000 ms
PING 127.0.0.25 (127.0.0.25) 56(84) bytes of data.
64 bytes from 127.0.0.25: icmp_req=1 ttl=64 time=0.034 ms
--- 127.0.0.25 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.034/0.034/0.034/0.000 ms
PING 127.0.0.26 (127.0.0.26) 56(84) bytes of data.
64 bytes from 127.0.0.26: icmp_req=1 ttl=64 time=0.029 ms
--- 127.0.0.26 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.029/0.029/0.029/0.000 ms
PING 127.0.0.27 (127.0.0.27) 56(84) bytes of data.
64 bytes from 127.0.0.27: icmp_req=1 ttl=64 time=0.032 ms
--- 127.0.0.27 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.032/0.032/0.032/0.000 ms
PING 127.0.0.28 (127.0.0.28) 56(84) bytes of data.
64 bytes from 127.0.0.28: icmp_req=1 ttl=64 time=0.031 ms
--- 127.0.0.28 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.031/0.031/0.031/0.000 ms
PING 127.0.0.29 (127.0.0.29) 56(84) bytes of data.
64 bytes from 127.0.0.29: icmp_req=1 ttl=64 time=0.028 ms
--- 127.0.0.29 ping statistics ---
后面省略