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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Masking input 1

Status
Not open for further replies.

amac14

Programmer
Apr 26, 2004
9
CA
Is there a way to mask user input with ***'s or to "blank" out the input and not display it on the screen? I am looking for something similar to the "passwd" functionality, when a user types in their old and new password it is not displayed on the screen.

Any help is appreciated.
 
Hi,

# save terminal settings
typeset OLDSTTY=$(stty -g 2>/dev/null)
# change terminal setting (echo off)
stty -icanon -echo min 1 time 0 2>/dev/null

# read some VARS without echo
read PASS?"enter your password : "
print
read CPASS?"Confirme password : "
# restore saved terminal setting to enable echo
stty $OLDSTTY 2>/dev/null
#... continue your script

Ali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top