Bash test if port is open no external tools

Assume you do not have curl/telnet/netcat (or nc does not support -z as in later versions ?? why did they remove it ?? ) the following will work on any recent Bash version.

(echo > /dev/tcp/skinner/22) >/dev/null 2>&1 && echo "Port is open" || echo "Port is closed"

nJoy 😉


Leave a Reply

Your email address will not be published. Required fields are marked *