Differences in nc (netcat) options on Ubuntu vs RedHat

5

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?

bguiz

Posted 2011-04-12T02:36:47.360

Reputation: 1 651

3

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 – 2015-06-22T05:17:54.343

Answers

0

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}
done

is sufficient?

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

Mikel

Posted 2011-04-12T02:36:47.360

Reputation: 7 890