I try to get zookeeper stat from shell by using nc
,
call nc localhost 2181
first, then type in: stat works.
while echo "stat" | nc localhost 2181
returns nothing.
why?
Asked the same question in Zookeeper mail list, and got this:
Most probably you are using the wrong "nc" command.
Not kidding :P there are two different "nc" packages, and the syntax is different betweem then. In debian-like distros they are netcat-openbsd and netcat-traditional, but I ran into the same problems with netcat in CentOS (I can't remember the name of the packages, sorry) until I realized I was using it wrong.
--Tomas Nunez
I found that the nc on my server is nc.openbsd, after install nc.traditional,
echo "stat" | nc.traditional 10.18.10.30 2181
returns the expected result.
I found that adding a wait with the -q
param to the nc
command resulted in the expected output.
echo "ruok" | nc -q 2 localhost 2181
worked for me on Ubuntu systems. You may need to use -w
instead of -q
on OpenBSD systems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With