From a bash script how can I quickly find out whether a port 445 is open/listening on a server.
I have tried a couple of options, but I want something q
There's a very short with "fast answer" here : How to test if remote TCP port is opened from Shell script?
nc -z ; echo $?
I use it with 127.0.0.1 as "remote" address.
this returns "0" if the port is open and "1" if the port is closed
e.g.
nc -z 127.0.0.1 80; echo $?
-z Specifies that nc should just scan for listening daemons, without sending any data to them. It is an error to use this option in conjunc- tion with the -l option.