General discussion


Suppress Keyboard strokes on Console

By Jayanth ·
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.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by ghislain.levesque In reply to Suppress Keyboard strokes ...

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.

Collapse -

by Jayanth In reply to

Nope, this is not what I require. I need something similar on Windows.

Collapse -

by Jayanth In reply to Suppress Keyboard strokes ...

This question was closed by the author

Related Discussions

Related Forums