[raspberry-vi] Re: checking for an Internet connection

  • From: Tim Chase <raspberry-vi@xxxxxxxxxxxxxxxxx>
  • To: raspberry-vi@xxxxxxxxxxxxx
  • Date: Sun, 24 Mar 2013 17:52:30 -0500

On March 23, 2013, Glenn wrote:
> Is there something I can type in the CLI that would give me
> audio feedback if I am connected to the WIFI?

It depends on whether you also plan to have it connected to the
internet via a LAN connection.  If you plan to *only* use WiFi, then
you can test for an active route to the internet and respond
accordingly.  Something like

  ping -c1 yahoo.com && echo "connected" || echo "disconnected"

which could then be routed to say the text if you want.  Or you could
do something like

  ping -c1 yahoo.com && play connected.wav || play disconnected.wav

to play a sound.


If you want to be notified upon the actual connection (rather than
having an easy way to test manually), and you're using
NetworkManager, you can create a script in /etc/network/if-up.d/ that
will notify you.  There should be some sample scripts in there which
you can use as a starting point.

-tim




=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

Other related posts: