Upon reboot and login, I want to check to see if a remote computer (10.1.0.53) is listening for UDP on port 2222. I have tried adding the following line to ~/.bashrc (later, I tried ~/.profile, with the same result):
nc -z -u -v 10.1.0.53 2222
Upon reboot, I get the message:
nc: connect to 10.1.0.53 port 2222 (UDP) failed: Network is unreachable
If I immediately try source .bashrc
at the prompt, it succeeds and outputs:
Connection to 10.1.0.53 2222 port [udp/*] succeeded!
How do I make netcat wait until the network is reachable? (10.1.0.53 is listening the entire time).