- 论坛徽章:
- 0
|
本帖最后由 luxinjun888 于 2012-05-22 14:54 编辑
chenyx 发表于 2012-05-22 11:07 ![]()
或者,你修改下ping $i >> /home/ping.txt行
改成abc=`ping -c 1 $i`
然后echo $DAT $abc >> ping.txt
----------------------------------------------------------------------
非常感谢chenyx,在你的帮助下改成这样了,差不多已经满足他们要求了,呵呵 :
#!/bin/bash
i=`cat /home/baoding`
while [ 1 ]
do
DAT="`date +%Y%m%d-%H:%M:%S`"
cat baoding | while read i
do
echo $i
abc=`ping -c 1 $i`
echo $DAT $abc >> ping.txt
done
done
20120424-09:04:06 PING 111.111.111.111 (111.111.111.111) 56(84) bytes of data. 64 bytes from 111.111.111.111: icmp_seq=1 ttl=50 time=55.9 ms --- 121.18.231.3 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 55.978/55.978/55.978/0.000 ms
20120424-09:04:06 PING 222.222.222.222 (222.222.222.222) 56(84) bytes of data. 64 bytes from 222.222.222.222: icmp_seq=1 ttl=50 time=53.1 ms --- 121.18.231.4 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 53.119/53.119/53.119/0.000 ms
20120424-09:04:06 PING 333.333.333.333 (333.333.333.333) 56(84) bytes of data. 64 bytes from 333.333.333.333: icmp_seq=1 ttl=50 time=63.1 ms --- 121.18.231.2 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 63.177/63.177/63.177/0.000 ms
|
|