Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-20-2004, 08:38 PM   #1
Registered: Jul 2004
Posts: 31

Rep: Reputation: 15
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?)
Old 07-20-2004, 09:51 PM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
stty_orig=`stty -g` 
stty -echo 
read secret 
stty $stty_orig
I got this from here:
Old 07-20-2004, 09:52 PM   #3
Registered: Feb 2004
Posts: 467

Rep: Reputation: 30
You can turn off the echo on the terminal.
echo -n "login: "
read user
echo -n "Password: "
stty -echo
read pass
stty echo
Old 07-20-2004, 10:17 PM   #4
Registered: Jul 2004
Posts: 31

Original Poster
Rep: Reputation: 15
Great, thank you!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I take input with a shell script? GUIPenguin Linux - General 4 04-11-2005 03:46 PM
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 03:14 AM
mask user input in a bash script PlatinumRik Linux - Software 1 06-15-2004 10:06 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
User input using a BASH script... causticmtl Programming 5 07-13-2003 09:59 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration