LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to play beep sound inside shell script? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-play-beep-sound-inside-shell-script-895465/)

hk_centos 08-04-2011 02:31 AM

how to play beep sound inside shell script?
 
Hi All,

I need to make beep sound inside my basic shell script.

ex:
#!/bin/sh

if ping 172.16.XXX.XXX
then
echo " Server is running "
else
#--- make system sound--------

echo " Server idle "
fi

note:
how to check my linux system is working with these system sounds ?

ex :
$] beep

there were no any sound play through speaker
but
system --> preferences--> sound
all testing stages are successful.

Regards,
HK

Fantasio 08-04-2011 03:49 AM

aplay is your friend
 
An alternative is to use "aplay soundfile.wav".
In a shell script, you can use the command echo -e "\a" or the command mentionned just before.

jdkaye 08-04-2011 04:48 AM

This script seems to work (run as root)
Code:

#!/bin/bash
if [ "$1" = on ];then
micro_inetd 55555 $0 &
else
echo -e '\a' >/dev/tty9
fi

More details are found here.
ciao,
jdk

salemeni 08-04-2011 04:58 AM

Hi
You can use the beep command

ex.

beep -f 300.7 -r 2 -d 100 -l 400

generics array

tredegar 08-04-2011 04:02 PM

beep only works if your PC has a "speaker". Many modern laptops / small devices don't have one.

hk_centos 08-05-2011 01:52 AM

Thanks All for ur suggestions,

Actually i used .wav file to make sound
just putting

if <condition>
then
play xxxxx.wav
fi

i thought why i'm think much about beep sound , i design a my solution using sound file

Best Regards ,
HK


All times are GMT -5. The time now is 02:47 AM.