Can we set up a voice for disconnetion?

Colin Law clanlaw at googlemail.com
Thu Oct 20 08:49:11 UTC 2011


On 20 October 2011 09:39, PM <ubuntu.bkn at gmail.com> wrote:
>>> Paste the following into a file and make it executable with chmod +x
>>>
>>> #!/bin/bash
>>> ping -q -c 3 www.google.com > /dev/null
>>> rc=$?
>>> if [ ${rc} -ne  0 ]
>>> then
>>> espeak "Internet connection may be down" >/dev/null 2>&1
>>> fi
>>
>> Would save the file with the name alert.sh and I should make it executable
>> like this:
>>
>> sudo chmod +x alert.sh (I googled it)
>>
>>> Call this shell script in your crontab as frequently as you'd like to
>>> check the connection.
>>
>> I don't know how to call it in the crontab? (I am new...)
>>
>>>
>>> Adjust this ping command to suit your needs.
>>
>> After learning something, I would try to do this.
>>
>>>
>>> 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.
>>
>> How to set a mp3 song here (if possible)?
>>
>>> 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.
>>
>> Yeah thanks. If I don't open any browser, it would directly intimate me by
>> the voice alert...?
>
> I did but when I disconnected the INTERNET, this script doesn't run as no
> voice came from the PC!

So put some debug in the script and work out why.
If you don't know how to do that then look for some tutorials on bash scripting.

Colin




More information about the ubuntu-users mailing list