[sf-lug] system beep

Akkana Peck akkana at shallowsky.com
Fri Jan 8 10:17:05 PST 2010


> On Thu, 2010-01-07 at 17:49 -0800, Alex Kleider wrote:
> > if at the linux command line (bash shell) I type
> > $ echo $'\a'
> > the bell rings

jim writes:
> when i use the command 
> $ echo $'\a' 

Another way is to tell bash to print the beep character (ctrl-G, ASCII 7):
$ echo -e "\007"

But when I put either one in a script and run it through at, the
problem seems to be that at is redirecting the output, so the ctrl-G
never goes to a terminal that can turn it into sound. Try adding
some visible text in your script:

echo BEEP $'\a'

and you'll see that you never see the BEEP either if you call it
from at.

If you explicitly redirect it to a terminal, it works.
For instance, type tty to find out what your current terminal is,
then put that in the script:

echo BEEP $'\a' >/dev/pts/1

and call it from at, and it should work (it did for me).

But that's not very convenient if you want to schedule a script to run
days fom now, since you'd have to be sure what pty is there that
you can write to.

If your script can run as root, you could use the console:

echo $'\a' >/dev/console

Or if you're pretty sure you'll be logged in on the console as
your own user, you could use tty0 or tty1:

echo $'\a' >/dev/tty1

	...Akkana




More information about the sf-lug mailing list