nc: invalid option -- 'z'
maybe nc is a link to ncat, use the commands to checkļ¼
which nc | xargs ls -l
if the nc is linked to ncat,you should relink nc to netcat, if netcat is not installed, refer the website:http://netcat.sourceforge.net/download.php
It seems the old version of nc
is being phased out everywhere in favour of Nmap Ncat. Unfortunately this doesn't have the rather useful -z
option.
One way to get equivalent functionality (test whether the target host is listening on a given port) is to transform this:
nc -z hostname port
Into this:
cat /dev/null | nc hostname port
You might also want to add in an option like -w 1s
to avoid the long default timeout.
There might be a cleaner combination of options that avoids the need for the /dev/null
but I couldn't figure out what.
I've also seen talk of using tcping
to do the same thing, but that doesn't seem to be available on all distros.