From 4da431f20853b50e46215012b080dda36b0a9312 Mon Sep 17 00:00:00 2001 From: redrainl <61587864+redrainl@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:23:48 +0800 Subject: [PATCH] Update speedtest_bestv.sh --- speedtest/speedtest_bestv.sh | 39 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/speedtest/speedtest_bestv.sh b/speedtest/speedtest_bestv.sh index 3250fe169..017b14a5f 100644 --- a/speedtest/speedtest_bestv.sh +++ b/speedtest/speedtest_bestv.sh @@ -1,6 +1,24 @@ -rm -f speedtest_bestv.log +#!/bin/bash + +read -p "确定要运行脚本吗?(y/n): " choice + +# 判断用户的选择,如果不是"y"则退出脚本,默认使用文件bestv.ip,带参数则以参数为ip文件名 +if [ "$choice" != "y" ]; then + echo "脚本已取消." + exit 0 +fi + +time=$(date +%m%d%H%M) i=0 + +if [ $# -gt 0 ]; then + filename="$1" + else + filename="bestv.ip" +fi + while read line; do + i=$(($i+1)); ip=$line date1=$(date +%Y%m%d%H) @@ -8,11 +26,16 @@ while read line; do a=${a:0:9} a=`expr $a - 7` url2="$date1/$a.ts" - url="http://$ip/liveplay-kk.rtxapp.com/live/program/live/cctv1hd8m/8000000/$url2" - curl $url --connect-timeout 2 --max-time 15 -o /dev/null >dl.log 2>&1 - a=$(tail -n 1 dl.log|awk '{print $NF}') +# url="http://$ip/liveplay-kk.rtxapp.com/live/program/live/cctv1hd8m/8000000/$url2" + + url="http://$ip/liveplay-kk.rtxapp.com/live/program/live/gswshd8m/8000000/$url2" + echo $url + curl $url --connect-timeout 2 --max-time 15 -o /dev/null >bestv.tmp 2>&1 + a=$(tail -n 1 bestv.tmp|awk '{print $NF}') echo "第$i个: $ip $a" - echo "$ip $a">> speedtest_bestv.log - -done -cat speedtest_bestv.log |grep M|awk '{print $2" " $1}'|sort -r |head -n 10 + echo "$ip $a">> speedtest_bestv$time.log + + +done <"$filename" +rm -f bestv.tmp +cat speedtest_bestv$time.log |grep -E 'M|k'|awk '{print $2" " $1}'|sort -n -r