Discussion Locked

Suppress Keyboard strokes on Console

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am writing an application in Perl. This application will take the 'username' and the 'password' as the input, and based on the authentication from the Windows Domain Controller will continue to process other things. This same Perl Script is also used on Unix and here the authentication is done from NIS.

The script runs in a DOS Box on Windows and in a Terminal on Unix (there is no GUI). My main concern is, when users are typing their passwords, how to suppress it from appearing on the console in the DOS Box. In Unix there is a command called "stty -echo" which will turn off the console echo. Is there a similar command on Windows? Or is there any way by which I could achieve the same through Perl.

Any pointer or hints will be appreciated.

3 replies

by ghislain.levesque

Here is a little shell function that will read 1 char at the time....

old_stty="`stty -g`"
stty -echo raw
user_key="`dd bs=1 count=1 2> /dev/null`"
echo "*\c" >&2
stty $old_stty

So, all you have to do is to call that function until "ENTER" is press... Each time it's call $user_key contain 1 charc of the password. Just concatenate it to another variable.

This discussion is closed to new replies.