Last active
January 21, 2021 13:29
-
-
Save VincentSit/8797d26f7be2364778f8 to your computer and use it in GitHub Desktop.
批量 ping 云梯 VPN 服务器.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author : VincentSit | |
# Copyright (c) http://xuexuefeng.com | |
# 批量 ping 云梯 VPN 服务器. | |
# 请将 example.com 替换为你的专属服务器地址. | |
HOSTS=("日本1号:jp1.example.com" | |
"日本2号:jp2.example.com" | |
"日本3号:jp3.example.com" | |
"美国1号:us1.example.com" | |
"美国2号:us2.example.com" | |
"美国3号:us3.example.com" | |
"美国4号:us4.example.com" | |
"美国5号:us5.example.com" | |
"新加坡1号:sg1.example.com" | |
"新加坡2号:sg2.example.com" | |
"台湾1号:tw1.example.com" | |
"香港1号:hk1.example.com" | |
"香港2号:hk2.example.com" | |
"英国1号:uk1.example.com") | |
for host in ${HOSTS[@]}; | |
do { | |
name=${host%%:*} | |
domain=${host#*:} | |
pingResults=`ping -c 1 ${domain}` | |
if [ $? -ne 0 ]; then | |
echo "\033[31m ${name}(${domain}) 无法连接!\033[0m" | |
else | |
avg=`echo ${pingResults} | awk -F"/" '{print $5}'` | |
echo ${name}": "${avg}" ms" | |
fi | |
}& | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good job! Thank you very much!