I would like to use netcat
to send a piece of text to the echo service on my server, get the reply then exit, so that I know the connection is still good. so far I've tried:
echo 'test' | netcat server 7
this way netcat would wait for more input rather than exit.
How can I make netcat
exit after getting reply from the echo service?
Best Answer
Just tried - slightly different behaviour between
netcat-openbsd
andnetcat-traditional
( ubuntu 16.4). The OpenBSD variant does what you expect, while with the netcat-traditional I need to add the-q 1
to avoid waiting for more input.