netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@xenotime.net>
To: Christian Boltz <netdev-vger-kernel.org@cboltz.de>
Cc: netdev@vger.kernel.org
Subject: Re: Feature request: "inverted" ping -a (beep on failure)
Date: Fri, 15 Apr 2011 13:14:04 -0700	[thread overview]
Message-ID: <20110415131404.bad26a5a.rdunlap@xenotime.net> (raw)
In-Reply-To: <201104152211.46180@tux.boltz.de.vu>

On Fri, 15 Apr 2011 22:11:45 +0200 Christian Boltz wrote:

> Hello,
> 
> Am Freitag, 15. April 2011 schrieb Randy Dunlap:
> > On Fri, 15 Apr 2011 21:35:32 +0200 Christian Boltz wrote:
> > > I'd like to have the exact opposite of it: beep when pinging fails.
> [...]
> > Couldn't you look for exit code (status) 1 and then do a bell/beep
> > (or play a sound file :)?
> 
> That would require that I know in advance when exactly the server is 
> unreachable - but in this case, I wouldn't need to ping it ;-)

I didn't follow that, but it's OK.

> To have this working, ping would need an option "exit on error", which 
> it doesn't have AFAIK.

'man ping' discusses exit status codes:

       If  ping  does  not  receive any reply packets at all it will exit with
       code 1. If a packet count and deadline are both  specified,  and  fewer
       than  count  packets are received by the time the deadline has arrived,
       it will also exit with code 1.  On other error it exits  with  code  2.
       Otherwise  it exits with code 0. This makes it possible to use the exit
       code to see if a host is alive or not.


> A workaround is to run ping -c1 in a loop:
> 
> while true ; do       If  ping  does  not  receive any reply packets at all it will exit with
       code 1. If a packet count and deadline are both  specified,  and  fewer
       than  count  packets are received by the time the deadline has arrived,
       it will also exit with code 1.  On other error it exits  with  code  2.
       Otherwise  it exits with code 0. This makes it possible to use the exit
       code to see if a host is alive or not.
>     ping -c1 $server || beep
>     sleep 1
> done
> 
> but I'd prefer to have something like this directly in ping ;-)
> 
> > Or do you want ping to beep and then continue running?
> 
> Yes, that's exactly what I want.


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

  reply	other threads:[~2011-04-15 20:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 19:35 Feature request: "inverted" ping -a (beep on failure) Christian Boltz
2011-04-15 19:49 ` Randy Dunlap
2011-04-15 20:10   ` Denys Fedoryshchenko
     [not found]   ` <20110415124937.6e746646.rdunlap-/UHa2rfvQTnk1uMJSBkQmQ@public.gmane.org>
2011-04-15 20:11     ` Christian Boltz
2011-04-15 20:14       ` Randy Dunlap [this message]
2011-04-15 21:57 ` Martin Topholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110415131404.bad26a5a.rdunlap@xenotime.net \
    --to=rdunlap@xenotime.net \
    --cc=netdev-vger-kernel.org@cboltz.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).