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.