:: Re: [DNG] Testing network connectiv…
Startseite
Nachricht löschen
Nachricht beantworten
Autor: Steve Litt
Datum:  
To: dng
Betreff: Re: [DNG] Testing network connectivity
On Wed, 05 Jul 2017 01:57:05 +0200
Florian Zieboll <f.zieboll@???> wrote:

> Am 5. Juli 2017 01:07:21 MESZ schrieb Steve Litt
> <slitt@???>:
>
> > echo 'quit' | nc -w2 $1 $2 2>/dev/null 1>/dev/null
>
> For these kind of tests I use "nc -z $HOST $PORT". Like your
> suggestion, it not only proves the host to be up, but also the wanted
> service and times out after a couple of seconds, too - but you don't
> need the "> /dev/null 2>&1" redirection.


Yes!

You still need the 2>/dev/null and you still need the -w2 for very
rare hangs, but your version gets rid of a lot of objectionable stuff
including prepiping "quit".

So here's my revised version:

======================================
#!/bin/sh
nc -w2 -z $1 $2 2>/dev/null
return $?
======================================

Thanks!

SteveT

Steve Litt
July 2017 featured book: Quit Joblessness: Start Your Own Business
http://www.troubleshooters.com/startbiz