[comp.unix.questions] bells and beeps

ratzan@pilot.njin.net (Lee Ratzan) (05/13/91)

we are novice unix users running a hewlett-packard 9000/835 under
hp-ux (a berkeley and at &tt unix hybrid. how do we activate
a keyboard beep from within a korn shell script? the idea is
to warn users of invalid entries before the screen clears.

your assistance is appreciated.

thanx,

lee ratzan
univ of medicine and dentistry of nj
.

gordon@osiris.cso.uiuc.edu (John Gordon) (05/14/91)

	The standard way to beep is to echo a Control-G character (^G).

jimr@hplsdv7.COS.HP.COM (Jim Rogers) (05/14/91)

>we are novice unix users running a hewlett-packard 9000/835 under
>hp-ux (a berkeley and at &tt unix hybrid. how do we activate
>a keyboard beep from within a korn shell script? the idea is
>to warn users of invalid entries before the screen clears.
>
>your assistance is appreciated.
>
>thanx,
>
>lee ratzan
>univ of medicine and dentistry of nj

The simple answer is to use a control-G.  This will work in most cases.
The more general solution is to use the "tput" command and the terminfo
database (see man pages for "tput (1)" and "terminfo (4)").  The use
of tput allows the user to be on a wide array of terminal types and still
have the desired response by his/her terminal.

For the "beep" use the following mthod in your Korn shell:

beep=`tput bel`
print "${beep}"


Similar capabilities can be defined for text attributes (i.e. bold, normal),
cursor movement (i.e. home cursor, cursor down, cursor up), clear to
end of line or clear to end of screen, and so forth.


Jim Rogers
Hewlett-Packard Company

clewis@ferret.ocunix.on.ca (Chris Lewis) (05/15/91)

In article <May.13.12.56.58.1991.1079@pilot.njin.net> ratzan@pilot.njin.net (Lee Ratzan) writes:
>we are novice unix users running a hewlett-packard 9000/835 under
>hp-ux (a berkeley and at &tt unix hybrid. how do we activate
>a keyboard beep from within a korn shell script? the idea is
>to warn users of invalid entries before the screen clears.

Others will suggest echoing a control-G.  Which works on most terminals.
Most versions of UNIX (at least, ATT'ish ones) have a generic interface to
terminals called terminfo, in which each type of terminal is described
so that various applications can figger out how to control the terminal.
With terminfo, there is a command called "tput".  A slightly more generic
solution to getting a beep would be to call:
	tput bel
Which consults the database and emits the sequence required to get a bell.
Tho, in some cases, people have redefined it to do other "obvious" things.
(eg: inverse flash the screen - eugh ;-)

You can use tput to emit other things too without having to know the
interface to the terminal.
-- 
Chris Lewis, Phone: (613) 832-0541, Domain: clewis@ferret.ocunix.on.ca
UUCP: ...!cunews!latour!ecicrl!clewis; Ferret Mailing List:
ferret-request@eci386; Psroff (not Adobe Transcript) enquiries:
psroff-request@eci386 or Canada 416-832-0541.  Psroff 3.0 in c.s.u soon!

decot@hpcupt1.cup.hp.com (Dave Decot) (05/15/91)

> we are novice unix users running a hewlett-packard 9000/835 under
> hp-ux (a berkeley and at &tt unix hybrid. how do we activate
> a keyboard beep from within a korn shell script? the idea is
> to warn users of invalid entries before the screen clears.

    echo "You made a mistake!^G"

where ^G means you hit control-G at that point in entering the script.

Dave