Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to delay the script execution until a certain server process is ready, which it is once it accepts incoming TCP connections.

How do I test if a local TCP port is open (I get a SYN/ACK answer)?

share|improve this question
1  

1 Answer 1

up vote 2 down vote accepted

I would use lsof if available for this purpose. You can grep the output to check for a line of output with a LISTEN condition for the port in question. Some options may have to be passed to prevent converting port names to symbolic, etc, see man lsof for details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.