beep
beep
– produce a beeping noise, by any available method
beep [ -v ] [ -Xkb | -X | -T | -S ]
beep
is a command-line utility for making a computer go beep.
Under normal circumstances, you should be able to use it just by typing ‘beep
’, with no options.
The traditional method of producing a beep in a shell script is to write an ASCII BEL (\007
) character to standard output, by means of a shell command such as ‘echo -ne '\007'
’. This only works if the calling shell's standard output is currently directed to a terminal device of some sort; if not, the beep will produce no sound and might even cause unwanted corruption in whatever file the output is directed to.
There are other ways to cause a beeping noise. A slightly more reliable method is to open /dev/tty
and send your BEL character there. This is robust against I/O redirection, but still fails in the case where the shell script wishing to generate a beep does not have a controlling terminal, for example because it is run from an X window manager.
A third approach is to connect to your X display and send it a bell command. This does not depend on a Unix terminal device, but does (of course) require an X display. The X server supports two different methods of requesting a bell (the Xkb extension and the basic X11 protocol), and beep
will try both in turn.
The beep
command supports all these methods of generating a beep, and will try them in order until one works. Its order of preference is to use the X server, then to fall back to /dev/tty
, and if all else fails it will simply write a BEL to its standard output.
-Xkb
beep
to only using the Xkb extension on the X server to generate its beep. If there is no X server available, or it does not support the Xkb extension, no beep will be generated and beep
will return failure.
-X
beep
to only using the basic X11 protocol on the X server to generate its beep. If there is no X server available, no beep will be generated and beep
will return failure.
-T
beep
to only using /dev/tty
to generate its beep. If /dev/tty
cannot be opened or written to, no beep will be generated and beep
will return failure.
-S
beep
to only using standard output to generate its beep. If its standard output cannot be written to, no beep will be generated and beep
will return failure.
-v
beep
to log everything it did even if it succeeds. By default, error messages will only be output if none of the available beep methods succeeded.
beep
will return a success (0) status if it thinks it successfully beeped, and failure (1) otherwise.
None known at present.
beep
is free software, distributed under the MIT licence. Type beep --licence
to see the full licence text.