I am using following piece of code on Ubuntu 14.4 to check whether ssh port in my remote machine is open or not
$PROXY_SERVER_IP=192.168.1.40
$LOGGER "Waiting for Proxy-VM ssh port to become active.."
while ! nc -z $PROXY_SERVER_IP 22; do
sleep 10s
done
Above code works some time but other time it result in infinite loop with following message
This is nc from the netcat-openbsd package. An alternative nc is available
in the netcat-traditional package.
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port]
[-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]
[-x proxy_address[:port]] [hostname] [port[s]]
Is there any other way to to know whether port is open or not ?