我正在从一个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"发布于 2014-08-22 02:44:45
使用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. https://stackoverflow.com/questions/24792544
复制相似问题