【问题标题】:Network monitoring ping网络监控ping
【发布时间】:2014-07-16 23:30:26
【问题描述】:

我正在从一个 txt 文件中读取数百个 IP 地址,想将列表 ping 到文件末尾。希望它在循环中运行,读取到文件末尾,然后再次从第一个地址开始。

trap 'echo ****Interrupted****; exit'INT

echo -n "Enter the file name with the ip addresses"
read file

echo -n "Enter the file name for the log file"
read log

while read line
do
echo "pinging: "$line
echo -e "">>$log
echo -n "NEXT PING: ">>$log
echo -n "$line" : " >>$log
$ping -c 3 -W 2 $line >>$log
done <"$file"

【问题讨论】:

  • true 条件将你的while循环包裹在另一个while循环中。也许while true ; do while read line ; do ...... done &lt; "$file" ; sleep 5 #?; done祝你好运。

标签: bash loops


【解决方案1】:

使用fping

http://fping.org/

来自fping 手册页:

DESCRIPTION
   fping  is  a  program  like ping(8) which uses the Internet Control Message 
   Protocol (ICMP) echo request to determine if a target host is responding.
   fping differs from ping in that you can specify any number of targets on the 
   command line, or specify a file containing the lists of targets to ping.
   Instead  of  sending  to  one target until it times out or replies, fping will
   send out a ping packet and move on to the next target in a round-robin
   fashion. 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多