Can we set up a voice for disconnetion?

Steve Flynn anothermindbomb at gmail.com
Thu Oct 20 12:52:35 UTC 2011


On 20 October 2011 13:34, PM <ubuntu.bkn at gmail.com> wrote:

>
> Make sure you have espeak package installed. The /dev/null redirection
>> will hide any error messages.
>>
>
> The package is installed.
>
>
>> To verify, type
>> espeak  "Internet connection may be down"
>> on a command line.
>>
>
> Yes it speaks.
>
>
Excellent.


> But in fact, that script is not working. Here is what I did:
>
> Just copied the following line:
>
>
> #!/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
>
> in a file and named it as* alert.sh*. After this went to the terminal and
> run::
> *
> sudo chmod +x alert.sh*
>
>
OK - so you've created the script on your machine, and you've flagged it as
executable. All well and good.

What you've not done is run it though.

Try disconnecting your internet, and start the script - you should find it
tells you that you are offline.



> Disconnected the net but no sound came! What should I do?
>
>
You need to make the script run repeatedly - say every 5 minutes. When it
does run it'll check your connection and either shout or be quiet.

the trick is getting it to run automatically. Best way is with a cron job.

To set this up enter the following:

crontab -e


This will drop you into your editor - add the following line:

 0,5,10,15,20,25,30,35,40,45,50,55 * * * * some/path/alert.sh >/dev/null

you need to replace "some/path" with the full path to wherever you stored
your alert.sh script. I can't tell you what this would look like unless I
know where you stored the script

Once you're done, save the file and exit your editor. The script will now
run every 5 minutes (5,10,15,20, etc) minutes past every hour of every day.
For full details on the syntax of the cron file, check out "man cron" - it's
a little bit unfriendly but it's quite simple once you get your head around
it.

-- 
Steve

When one person suffers from a delusion it is insanity. When many people
suffer from a delusion it is called religion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20111020/046d4608/attachment.html>


More information about the ubuntu-users mailing list