Re: nc missing option -z

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/13/2013 05:37 PM, Suvayu Ali wrote:
> 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.  :-/
>

I don't think that works very well.....    Checking a port which isn't used...

[egreshko@meimei ~]$ nmap -Pn -p666 imap.gmail.com

Starting Nmap 6.01 ( http://nmap.org ) at 2013-02-13 17:41 CST
Nmap scan report for imap.gmail.com (173.194.64.109)
Host is up.
Other addresses for imap.gmail.com (not scanned): 173.194.64.108
rDNS record for 173.194.64.109: oa-in-f109.1e100.net
PORT    STATE    SERVICE
666/tcp filtered doom

Nmap done: 1 IP address (1 host up) scanned in 2.06 seconds

And you still get "Host is up" but, of course, the service you want isn't....

I would still use tcping....

[egreshko@meimei ~]$ tcping -t 1 imap.gmail.com 993
imap.gmail.com port 993 open.
[egreshko@meimei ~]$ echo $?
0
[egreshko@meimei ~]$ tcping -t 1 imap.gmail.com 666
imap.gmail.com port 666 user timeout.
[egreshko@meimei ~]$ echo $?
2


-- 
Don't be bullied by the judgmental grammar and spelling police.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux