Netcat to the rescue waiting for a Windows 10 upgrade to finish (which can take hours):
while ! nc -z 172.22.0.67 3389; do echo "sleeping"; sleep 10; done; echo 'The server is up!'
Via: [WayBack] tcp – How can I trigger a script when a certain port becomes available for requests? – Unix & Linux Stack Exchange, quoting from the answer:
nc
is Netcat, “the Swiss-army knife for TCP/IP”,-z
means: do not send any data, just check if the port is open,while ! nc -z …; do sleep 0.1; done
: keep checking and sleeping for one tenth of a second until the port opens up, i.e. Netcat returns with a zero (success) status.
–jeroen