我在Ubuntu 14.4上使用以下代码来检查远程机器中的ssh端口是否打开
$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
上面的代码工作了一段时间,但其他时间导致无限循环,后面跟着消息
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]]
还有其他方法可以知道端口是否打开?