<div class="gmail_quote">On 19 October 2011 22:32, PM <span dir="ltr"><<a href="mailto:ubuntu.bkn@gmail.com">ubuntu.bkn@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><div></div></div><div>Sure - I'll boot up the laptop and crank it out now.<br>


</div></div></blockquote></div></div></blockquote></div><div><br></div><div>Paste the following into a file and make it executable with chmod +x</div><div><br></div><div><br></div><div><div>#!/bin/bash</div><div>ping -q -c 3 <a href="http://www.google.com">www.google.com</a> > /dev/null</div>

<div>rc=$?</div><div>if [ ${rc} -ne  0 ]</div><div>then</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>espeak "Internet connection may be down" >/dev/null 2>&1</div><div>fi</div>

</div><div><br></div><div>Call this shell script in your crontab as frequently as you'd like to check the connection. </div><div><br></div><div>It'll try to fire 3 packets to <a href="http://www.google.com">www.google.com</a> and will fail with a non-zero return code if it doesn't get a reply. Adjust this ping command to suit your needs.</div>

<div><br></div><div>Regardless of what happens with ping, we look at the return code and if it's not equal to zero we call espeak with a suitable message. This is where you'd pop your call to an mp3, an alarm noise, fire an email, log into the router and request it to reset itself, etc.</div>

<div><br></div><div>This is, as you can see, a simplistic script - you could easily extend it to have multiple attempts before deciding the link was down, or hit multiple sites multiple times before alerting anyone and so forth. No error handling in this thing right now - it's not something I'd deploy to a server at work for example but it shows you the general idea.</div>

<div><br></div><div><br></div><div><br></div>-- <br>Steve<br><br>When one person suffers from a delusion it is insanity. When many people suffer from a delusion it is called religion.<br><br>