<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div></div><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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" target="_blank">www.google.com</a> > /dev/null</div>
<div>rc=$?</div><div>if [ ${rc} -ne 0 ]</div><div>then</div><div><span style="white-space:pre-wrap"> </span>espeak "Internet connection may be down" >/dev/null 2>&1</div><div>fi</div>
</div><div></div></blockquote></div><div><br>Would save the file with the name <b>alert.sh</b> and I should make it executable like this:<br><b><br>sudo chmod +x alert.sh</b> (I googled it)<br><br></div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div></div><div>Call this shell script in your crontab as frequently as you'd like to check the connection.</div></blockquote></div><div><br>I don't know how to call it in the crontab? (I am new...)<br> <br></div>
<div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div></div><div>Adjust this ping command to suit your needs.</div></blockquote></div><div><br>After learning something, I would try to do this.<br> <br></div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div></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>
</blockquote></div><div><br>How to set a mp3 song here (if possible)? <br><br></div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div></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.<br>
</div></blockquote></div></div><br>Yeah thanks. If I don't open any browser, it would directly intimate me by the voice alert...?<br></blockquote></div><br>I did but when I disconnected the INTERNET, this script doesn't run as no voice came from the PC!<br>