测试域名ping延迟脚本

#!/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>&-

上一篇:spring boot使用mongodb时,xxxRepository不能Autowired的问题


下一篇:Path Sum的变体