#!/bin/bash
if [ $# -lt 1 ]
then
echo "Usage:avg file1"
exit 1
fi
echo "====================`date`======================" >> result.txt
function main {
time=`ping -c 10 -i 0.1 -q $1 | egrep "^rtt" | awk -F/ ‘{print $5}‘`
[[ "${time}" == "" ]] && echo -e "$1\ttime_out" >>result.txt || echo -e "$1\t${time}" >>result.txt
}
pipefile=/tmp/$$.fifo
mkfifo $pipefile
exec 5<>$pipefile
rm -rf $pipefile
for ((i=0;i<50;i++))
do
echo
done>&5
while read domain
do
read<&5
(main $domain && echo>&5)&
done <$1
wait
exec 5>&-
时间: 2024-09-29 08:34:34