mike (02/18/91)
>In an article, castle.ed.ac.uk!james (J Gillespie) writes: >Does anyone know of a way to prevent characters being echoed as they >are typed in? Like when you log in, your password doesn't get echoed. >I have a nasty feeling this may involve sending control codes to the >terminal. To disable echo on your terminal from within a program (assuming that you don't want to link in the curses library), and your system groks termio, then you can use this chunk of code: ----- cut here ------------------------------------------------------------- #include <termio.h> echo(state) int state; { static int setonce = 0; static struct termio old, new; if ( ! setonce ) { ioctl(0, TCGETA, &old); ioctl(0, TCGETA, &new); new.c_lflag &= ~ECHO; /* turn echo bit off */ setonce = 1; } if ( ! state ) ioctl(0, TCSETA, &new); else ioctl(0, TCSETA, &old); } ----------------------------------------------------------------------------- Thus, to turn the echo off, use echo(0), and to turn it back on echo(1). Hope this helps. Cheers, -- Michael Stefanik, MGI Inc., Los Angeles| Opinions stated are not even my own. Title of the week: Systems Engineer | UUCP: ...!uunet!bria!mike ------------------------------------------------------------------------------- Remember folks: If you can't flame MS-DOS, then what _can_ you flame?
navarra@casbah.acns.nwu.edu (John Navarra) (02/19/91)
In article <462@bria> uunet!bria!mike writes: >>In an article, castle.ed.ac.uk!james (J Gillespie) writes: >>Does anyone know of a way to prevent characters being echoed as they >>are typed in? Like when you log in, your password doesn't get echoed. >>I have a nasty feeling this may involve sending control codes to the >>terminal. > well, i suppose you could use all that c garbage if you are writing a c-program, but if you just want to turn off the echo do a stty -echo from within the script (or wherever) and a stty echo to turn it back on. ----------------- from the lab of the MaD SciEnTIst navarra@casbah.acns.nwu.edu