LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Masking user input in sh script? (https://www.linuxquestions.org/questions/linux-software-2/masking-user-input-in-sh-script-207633/)

RMSe17 07-20-2004 08:38 PM

Masking user input in sh script?
 
Hi, I have a question, I am writing a script that would accept username and password from the user, and do somethign with it.. My problem is that when I do

read username

to read what the user wrote, it also shows on the screen what they are typing. How can I make it so that it would not show on the screen what the user is typing? (or mask it with * or something?)

jschiwal 07-20-2004 09:51 PM

Code:

stty_orig=`stty -g`
stty -echo
read secret
stty $stty_orig

I got this from here:
http://www.tech-recipes.com/modules....ipes&rx_id=278

comp12345 07-20-2004 09:52 PM

You can turn off the echo on the terminal.
Code:

#!/bin/bash
echo -n "login: "
read user
echo -n "Password: "
stty -echo
read pass
stty echo


RMSe17 07-20-2004 10:17 PM

Great, thank you!


All times are GMT -5. The time now is 04:37 AM.