I do not know why you would expect output. From the man page:
-z Specifies that nc should just scan for listening daemons, without sending any data to them.
What happens if you connect to an http-server without sending any data? You get no response. Compare this with the normal cat
:
ljm@verlaine[~]$ touch this
ljm@verlaine[~]$ cat this
ljm@verlaine[~]$ cat that
cat: that: No such file or directory
this
is an empty file. So, for cat this
you get no answer. Not a message "hey I found this; but it is empty", but just the content of this
. It works the same way with nc
.
As an example, pi
listens to port 80 on my network.
ljm@verlaine[~]$ nc -z pi 80
ljm@verlaine[~]$ nc -z pi 83
pi.home [192.168.178.2] 83 (mit-ml-dev) : Connection refused
ljm@verlaine[~]$ echo -n "GET / HTTP/1.0\r\n\r\n" | nc pi 80
HTTP/1.1 404 Not found
Content-Type: text/plain
Content-length: 11
Not found
So, the first nc -z pi 80
connects to port 80 (which succeeds) sends nothing and does not get a reply.
The second nc -z pi 83
You get a message from nc
that explains what is wrong.
The third nc
sends some data to the webserver and gets an answer (a 404, but that is irrelevant)
ss -lt
.