Last active
October 10, 2022 11:39
-
-
Save euch/76ac478211e86f07d6a049661aff81aa to your computer and use it in GitHub Desktop.
Fake 'ping' for TCP-only environments. Return exit 0 if target port 22 is available.
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/sh | |
| PORT=22 | |
| HOST="${BASH_ARGV[0]}" | |
| echo -e Pinging $HOST on port $PORT over TCP | |
| if nc -z -v -w5 $HOST $PORT >/dev/null 2>&1; | |
| then | |
| echo "OK" | |
| exit 0 | |
| else | |
| echo "Connection failed" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment