Netcat command line issues

This works for me on debian using both nc.openbsd and nc.traditional:

echo -e "stats\nquit" | nc 10.251.170.80  11211

your netcat appears to be closing the connection on EOF on stdin and not waiting for output.. you can try -q 1 or so..

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


I tend to use a line like the following:

# (echo stats ; sleep 0.1) | netcat 10.251.170.80 11211

This seems to hold the connection open long enough to get the reply.