Created
November 18, 2019 02:16
-
-
Save realmovestar/b05b0c47cececb6c14512e4e47d082ee to your computer and use it in GitHub Desktop.
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 | |
# stdin에서 IP PORT 형식으로 입력 받아서 해당 서버에 접속가능한지 확인해줌. | |
check() { | |
echo -n "$1:$2 " | |
# timeout -k 5 5 | |
nc -z -w 5 $1 $2 &> /dev/null \ | |
&& echo -e '\e[32msucccess\e[0m' \ | |
|| echo -e '\e[31mfail\e[0m' | |
} | |
# IFS=$'\n' | |
while read entry; do | |
if [[ ${entry:=\#} = \#* ]]; then | |
echo $entry | |
continue | |
fi | |
temp=($entry) | |
IP="${temp[0]}" | |
PORT="${temp[1]}" | |
check $IP $PORT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment