Re: Using $PROMPT_COMMAND to beep depending on success/failure

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

 



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.

hth

Janina

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 www.google.com|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 www.google.com
> 
> 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 www.google.com && 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@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/blinux-list

-- 

Janina Sajka,	Phone:	+1.443.300.2200
			sip:janina@xxxxxxxxxxxxxxxxxxxx
		Email:	janina@xxxxxxxxxxx

Linux Foundation Fellow
Executive Chair, Accessibility Workgroup:	http://a11y.org

The World Wide Web Consortium (W3C), Web Accessibility Initiative (WAI)
Chair, Accessible Platform Architectures	http://www.w3.org/wai/apa

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list



[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]