nc missing option -z

Suvayu Ali fatkasuvayu+linux at gmail.com
Wed Feb 13 09:37:56 UTC 2013


On Wed, Feb 13, 2013 at 10:18:44AM +0100, Suvayu Ali wrote:
> On Wed, Feb 13, 2013 at 08:45:39AM +0000, James Hogarth wrote:
> >
> > The other alternative to tcping is nmap ...
> > 
> > nmap -Pn -p993 imap.gmail.com
> 
> I guess switching to nmap might resolve the second issue.
> 

This presents a different annoyance.  Now I have to parse the output to
determine if the port scan passed or failed since nmap returns 0
regardless of the results (which is understandable IMO).  Now something
simple like

  $ nc -z imap.gmail.com 993 &> /dev/null && { ... }

becomes

  $ nmap -Pn -p993 imap.gmail.com |& grep -q 'Host is up' && { ... }

And of course someday the printed text will change and I'll have to edit
my scripts again!  Oh well.  :-/

-- 
Suvayu

Open source is the future. It sets us free.


More information about the users mailing list