Using $PROMPT_COMMAND to beep depending on success/failure

Janina Sajka janina at
Fri Apr 22 16:51:34 UTC 2016

Some more options for testing network connectivity ...

ping -a

will beep the system for every returned packet. I find this so useful I
alias my ping command this way in bashrc.

Also, as Henry noted, using a specific IP address is probably a better
test, not just because it eliminates a step, but because that eliminated
step will also help you know your network is actually working when your
dns is failing. Sometimes named dies for me, and I find it helpful to
ascertain that my network is functioning except for that important
service--which I then simply restart.

Lastly, I find this kind of network pinging so useful, I've created two
scripts for myself in /usr/local/sbin, one called p4, the other called
p6. As you might guess, these ping a known server IP over IPv4 and IPv6
respectively. Quicker results for much less typing.



Tim Chase writes:
> On April 20, 2016, Jude DaShiell wrote:
> > Tim, thanks.  I have an application in mind for this.
> > What I've been doing so far to test network connected status was:
> > ping -c 5|grep %
> > That returns a line of output giving packet thruput statistics and
> > if I have 0 percent packet loss I know my network is up.  I just
> > need to figure out how to itegrate this.
> I'd simplify the test to something like
>   ping -c 1 -W 2
> which issues one ping and waits 2 seconds for a reply without the
> need for grepping. If it doesn't hear back, it will exit with a
> non-zero exit code, so you can simplify the test to
> PROMPT_COMMAND='ping -c 1 -W 2 && play -qn synth sin F3
> trim 0 0 0.1 fade 0 0.1 0.05 vol 0.2 || play -qn synth square F4 trim
> 0 0.1 fade 0 0.1 0.05'
> which will do the ping each time the prompt is displayed, and chirp
> based on success/failure.  This does mean that you might have up to a
> 2-second wait after every command if your network is down.
> If you really do want to sample the percentages, it would take a
> little more effort and might be worth running in the background and
> caching the result, then checking that cache in your PROMPT_COMMAND.
> -tim
> _______________________________________________
> Blinux-list mailing list
> Blinux-list at


Janina Sajka,	Phone:	+1.443.300.2200
			sip:janina at
		Email:	janina at

Linux Foundation Fellow
Executive Chair, Accessibility Workgroup:

The World Wide Web Consortium (W3C), Web Accessibility Initiative (WAI)
Chair, Accessible Platform Architectures

More information about the Blinux-list mailing list