PDA

View Full Version : [ubuntu] [SOLVED] Is there a command I can use in a script to make the PC speaker beep?



diablo75
November 12th, 2008, 01:45 AM
I'm making a bash script. I have a count down at the end of it that goes like this:


echo "All software has been installed. The system will reboot in 10 seconds" ## Displays the quoted message on screen
sleep 1; ##pauses the script for 1 second
echo "Restarting in 9 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 8 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 7 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 6 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 5 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 4 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 3 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 2 seconds. Press CTRL-C to cancel"
sleep 1;
echo "Rebooting in 1 second.. Press CTRL-C to cancel"
sleep 1;
init 6 ## reboots the computer

I'd like to add in some beeps to go with each echo.

Thanks!

nhasian
November 12th, 2008, 01:54 AM
how about the speaker-test command?

kaibob
November 12th, 2008, 01:57 AM
There's a utility in the repo's called beep. I just tried it, and it does what it says it does.

From the man page:


beep allows the user to control the pc-speaker with precision,
allowing different sounds to indicate different events. While it
can be run quite happily on the command line, it’s intended place
of residence is within shell/perl scripts, notifying the user when
something interesting occurs. Of course, it has no notion of
what’s interesting, but it’s real good at that notifying part.

All options have default values, meaning that just typing ’beep’
will work. If an option is specified more than once on the com‐
mand line, subsequent options override their predecessors. So
’beep -f 200 -f 300’ will beep at 300Hz.

sisco311
November 12th, 2008, 02:03 AM
try:

echo -e '\a'

or the beep command.


sudo aptitude install beep

diablo75
November 12th, 2008, 02:07 AM
There's a utility in the repo's called beep. I just tried it, and it does what it says it does.

This works. Thanks!

diablo75
November 12th, 2008, 02:08 AM
try:

echo -e '\a'



Actually this works better for me because I don't have to install anything. Thanks!