Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accepting the password 1

Status
Not open for further replies.

Ambatim

Programmer
Feb 28, 2002
110
IN
Hello Guys,

I am accepting the password from the user using 'read' command.

How can I make the password not to appear on the screen when the user is typing.

Thanks in advance

Regards
Mallik
 

oldmodes=`stty -g`
stty -echo
read password
stty $oldmodes
 
This has just *got* to be a FAQ by now -- vgersh99 do you want to do the honours?
Mike
______________________________________________________________________
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
vgersh99:

Since you're planning on creating a FAQ for changing the terminal driver, could you also add something like this:

# readkey: This function saves the current terminal settings and
# sets the terminal to raw mode with the unix stty command. Retrieve
# 1 character with the dd command and reset original terminal settings
# with stty before returning the character to calling script.
function readkey {
local anykey oldstty

oldstty=`stty -g`
stty -icanon -echo min 1 time 0
anykey=`dd bs=1 count=1 <&0 2>/dev/null`
stty $oldstty
echo $anykey
} # end read_key

Feel free to edit as you see fit.

Regards,

Ed
 
That's a new FAQ really Ed &quot;How do I get user input one char at a time?&quot;

Neat :) by the way, very neat; I've always avoided answering that question because I've never bothered to figure out how to do it! Mike
______________________________________________________________________
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Mike:

Thanks for the &quot;smiley face&quot;. Wish I could say I invented &quot;getting one character at a time&quot;, but one of my peers gave it to me sometime in the early '90s. He probably acquired it from somebody else.

I figured since Vlad was creating a FAQ on tweaking the terminal driver, this would fit in.

If you think it's reasonable I will place this in a FAQ of it's own. I haven't created one yet.

Regards,


Ed
 
yeah - I reckon, useful tip Mike
______________________________________________________________________
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top