Operating System - HP-UX
1753304 Members
6430 Online
108792 Solutions
New Discussion юеВ

Hiding characters entered in script

 
SOLVED
Go to solution
Pierce Byrne_1
Frequent Advisor

Hiding characters entered in script

I am writing a script which accepts a username and password to be used for connected to a third party app. I do not want the password to be displayed as it is typed.
I don't mind if each char is displayed as an asterix or just as blank.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Hiding characters entered in script

HI:

I answered this same question just a few days ago.

#!/usr/bin/sh

trap 'stty echo; exit' 0 1 2 3 15


echo "Enter Password: \c"
stty -echo
read PASSWD
stty echo

The trap is very important in case you kill this process or hit Ctrl-C; it returns the terminal to an echo state.


Regards, Clay


If it ain't broke, I can fix that.
Pierce Byrne_1
Frequent Advisor

Re: Hiding characters entered in script

Ta. That's spot on.
Pierce Byrne_1
Frequent Advisor

Re: Hiding characters entered in script

as detailed