Operating System - HP-UX
1829404 Members
2224 Online
109991 Solutions
New Discussion

Re: hide password of other info via shell script

 
SOLVED
Go to solution
eric stewart
Frequent Advisor

hide password of other info via shell script

I have a shell script the prompts the user for some information via the read command that I do not want to be displayed. The terminal type is vt200.
Is there a string that can be written to the terminal to turn display off and another to be turn the display back on?
It would be like echo off and echo on?
TIA
Good help is easy to find within forums
4 REPLIES 4
Antoanetta Naghiu
Esteemed Contributor

Re: hide password of other info via shell script

echo off and echo on is going to do the job.
Alan Riggs
Honored Contributor
Solution

Re: hide password of other info via shell script

You want something like:

echo "Enter password:"
stty -echo
read PASSWORD
stty echo
eric stewart
Frequent Advisor

Re: hide password of other info via shell script

Thanks Alan works great
Good help is easy to find within forums
Andreas Voss
Honored Contributor

Re: hide password of other info via shell script

Hi,

just an additional feature to Alans reply:
Within the script add the line:
trap "stty echo" 2 3 15
This ensures that if a user interrupts the script or get a termination signal at the read statement it will turn on echo back.

Cheers

Andrew