Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
nc -q -1 local host ${PORT} ${CMD}

In Ubuntu, nc may be used as above, with the -q option. See manpage.

  • -q after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever.

However, this option is not available in Redhat 5. See manpage. How do I achieve the equivalent of nc -q in Redhat 5?

share|improve this question
What version of netcat are you using? Did you compile from source, or install using your package manager? You might want to try compiling netcat from source, or attempting to compile the Ubuntu version on your Redhat machine. Also, it would be helpful to explain why you need this behaviour (specifically why you need to wait X seconds after EOF), as it might help to suggest alternative solutions. – Breakthrough Jun 22 '15 at 5:17

What do you want that option for? If you explain the use case, maybe we can come up with an alternative.

For example, maybe

while 1; do
    nc localhost ${PORT}

is sufficient?

I think the man pages is from RHEL5, but not 100% sure.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .