I need a command that will wait for a process to start accepting requests on a specific port.
Is there something in linux that does that?
while (checkAlive -host localhost -port 13000 == false) do some waiting ...
The best test to see if a server is accepting connections is to actually try connecting. Use a regular client for whatever protocol your server speaks and try a no-op command.
If you want a lightweight TCP or UDP client you can drive simply from the shell, use netcat. How to program a conversation depends on the protocol; many protocols have the server close the connection on a certain input, and netcat will then exit.
You can also tell netcat to exit after establishing the connection.
An alternative approach is to wait for the server process to open a listening socket.
Or you might want to target a specific process ID:
I can't think of any way to react to the process starting to listen to the socket (which would avoid a polling approach) short of using
If you have bash and coreutils (e.g. timeout, sleep), but not nc/lsof/netstat, you can use this solution which uses bash magic tcp sockets: