Test if remote TCP port is open from a shell script

With netcat you can check whether a port is open like this: nc my.example.com 80 < /dev/null The return value of nc will be success if the TCP port was opened, and failure (typically the return code 1) if it could not make the TCP connection. Some versions of nc will hang when you try this, because they do not close the sending half of their socket even after receiving the end-of-file from …

https://stackoverflow.com/questions/4922943/test-if-remote-tcp-port-is-open-from-a-shell-script