Created
March 9, 2022 21:12
-
-
Save mbierman/b694f963f7e32581b040f084082046ff to your computer and use it in GitHub Desktop.
See if there is a TCP port open at an IP
This file contains hidden or 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 | |
| ip=$1 | |
| port=$2 | |
| # port=${2:-5001} | |
| if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ $port =~ ^[0-9]* ]] ; then | |
| nc -vnz $ip $port | |
| exit | |
| else | |
| echo -e "Sorry you have to enter an IP and port?\n\n $(basename $0) [xxx.xxx.xxx.xxx port]" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment