[vox-tech] preventing display of typed text?

Mark K. Kim vox-tech@lists.lugod.org
Fri, 21 Jun 2002 05:45:33 -0700 (PDT)


For all UNIX scripting languages, I think using `stty` is the generic way
of turning off console echos:

   stty -echo

You can try it rigt now on the Linux console.  Anything you type won't
be echoed back to you, but you can still type commands.  Then to turn it
back on:

   stty echo

Of course, you won't see yourself typing that command, but you can still
type it and press enter to execute it.  BTW, make sure you check to make
sure the command was executed successfully first; it could otherwise be a
security problem on systems without the `stty` command.

But anyway, unfortunately that doesn't work on non-unix platforms.

You could always write a simple C program to handle non-echoing inputs.
I think getpass() C call is as universal as it gets (it's a unix call but
it's been adapted pretty widely, I hink).  Most UNIX should also support
the termios library for controlling terminal behavior (see `man termios`),
which I think is what stty uses anyway so that may be moot exercise.

-Mark


On Fri, 21 Jun 2002, Ryan wrote:

> On Thursday 20 June 2002 11:36 pm, Peter Jay Salzman wrote:
> > without checking, i've used 2 perl modules that might help:
> >
> > term which implements the advanced features that termcap provides like
> > underlining and boldfacing text
> >
> > ncurses which basically implements the C style ncurses library.
> >
> > i would imagine both modules allow you to do this.  in fact, i _know_
> > that C/ncurses has a function to block echo in raw mode.  i'm guessing
> > that perl/ncurses can do this too.
>
> I prefer a solution that is platform independant and non perl specific if
> possible, i.e., I may want to do something in bash or write a cross-platform
> perl script.
>
> --
> Breaking Windows isn't just for kids anymore...
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
>

--
Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.