From c6d6a62136f5bdb921af66fcb0dd9a533320f7ac Mon Sep 17 00:00:00 2001 From: redrainl <61587864+redrainl@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:59:50 +0800 Subject: [PATCH] =?UTF-8?q?Create=20=E4=B8=8A=E6=B5=B7=E7=BB=84=E6=92=AD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04\346\222\255\346\265\213\350\257\225.sh" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "speedtest/\344\270\212\346\265\267\347\273\204\346\222\255\346\265\213\350\257\225.sh" diff --git "a/speedtest/\344\270\212\346\265\267\347\273\204\346\222\255\346\265\213\350\257\225.sh" "b/speedtest/\344\270\212\346\265\267\347\273\204\346\222\255\346\265\213\350\257\225.sh" new file mode 100644 index 000000000..d970549a9 --- /dev/null +++ "b/speedtest/\344\270\212\346\265\267\347\273\204\346\222\255\346\265\213\350\257\225.sh" @@ -0,0 +1,35 @@ +#!/bin/bash + +read -p "确定要运行脚本吗?(y/n): " choice + +# 判断用户的选择,如果不是"y"则退出脚本,默认使用文件zubo.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="zubo.ip" +fi +lines=$(cat $filename|wc -l) + +echo "文件内ip共计$lines个" +while read line; do + i=$(($i+1)); + ip=$line + url="http://$ip/udp/239.45.3.209:5140" + echo $url + curl $url --connect-timeout 3 --max-time 10 -o /dev/null >zubo.tmp 2>&1 + a=$(head -n 3 zubo.tmp|awk '{print $NF}'|tail -n 1) + echo "第$i/$lines个: $ip $a" + echo "$ip $a">> speedtest_zubo$time.log +done <"$filename" + +rm -f zubo.tmp +cat speedtest_zubo$time.log |grep -E 'M|k'|awk '{print $2" " $1}'|sort -n -r >result_zubo.txt +cat result_zubo.txt