Creating a beep

Creating a beep

Post by John F » Tue, 02 May 2000 04:00:00



I am writing borne shell script.

I want to create a beep whenever a certain situation occurs.  What do I need
to put in the script to make the beep?

Thanks.

 
 
 

Creating a beep

Post by Sergio Mendoz » Tue, 02 May 2000 04:00:00


From the man page of bash:

Words of the form $'string' are treated specially.  The word
     expands   to   string,   with  backslash-escaped  characters
     replaced as specifed by  the  ANSI  C  standard.   Backslash
     escape sequences, if present, are decoded as follows:
          \a   alert (bell)

So:

   echo $'\a'   does BEEP...

Sergio.

 
 
 

Creating a beep

Post by Florian Stiass » Tue, 02 May 2000 04:00:00


tput bel
echo '\007\c'

---
                        \|/
                        o o
 ___________________oOO_(_)_OOo______________________________________

 
 
 

Creating a beep

Post by Christian Weisgerb » Tue, 02 May 2000 04:00:00



> I am writing borne shell script.

> I want to create a beep whenever a certain situation occurs.  What do I need
> to put in the script to make the beep?

Assuming your terminal beeps when sent the ASCII BEL character (as
universal a convention as there are any):

printf '\007'

--

 
 
 

Creating a beep

Post by S. Ferlion » Tue, 02 May 2000 04:00:00



> From the man page of bash:

> Words of the form $'string' are treated specially.  The word
>      expands   to   string,   with  backslash-escaped  characters
>      replaced as specifed by  the  ANSI  C  standard.   Backslash
>      escape sequences, if present, are decoded as follows:
>           \a   alert (bell)

> So:

>    echo $'\a'   does BEEP...

> Sergio.

Also try this if it is a shell script,
/bin/echo "\007"
does the same trick
 
 
 

Creating a beep

Post by Pa.Ped.it » Thu, 04 May 2000 04:00:00


Ciao John Fu,

 > I am writing borne shell script.
 >
 > I want to create a beep whenever a certain situation occurs.  What do I need
 > to put in the script to make the beep?

#!/bin/sh
# carillon.sh

# frequencies:
DO=330
DON=349
RE=370
REN=392
MI=415
FA=440
FAN=466
SOL=494
SOLN=523
LA=554
LAN=587
SI=622
XDO=660
XDON=698
XRE=740
XREN=784

NUM=$1

LENGHT=100
case $NUM in
        "1")  MELODY="$DO $RE $SI $LA $MI $SOL $FA $RE $DO";;
        "2")  MELODY="750 1000 2000 3000 4000 5000 4000 3000" ;;
        "3")  MELODY="$DO $RE $SI $LA $MI $SOL $FA $RE $DO"
                        LENGHT=50 ;;
        *)      MELODY="$DO $RE $SI $LA $MI $SOL $FA $RE $DO";;
esac

INTERVAL=`expr $LENGHT \* 3`

pause() { # null-loop INDEX times (I know, it'bad!)
        INDEX=$1
        until [ $INDEX -le 0 ] ; do INDEX=$((INDEX-1))
        done

Quote:}

carrilon() {
        for NOTE in $MELODY ; do
                echo -ne "\33[10;$NOTE]\33[11;$LENGHT]"
                echo -ne "\a"
#               pause 1000
                pause $INTERVAL
        done

Quote:}

carrilon

--

Pa.Ped, Como
http://www.fastflow.it/~paolop