LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-20-2004, 08:38 PM   #1
RMSe17
Member
 
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
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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
 
Old 07-20-2004, 09:52 PM   #3
comp12345
Member
 
Registered: Feb 2004
Posts: 467

Rep: Reputation: 30
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
 
Old 07-20-2004, 10:17 PM   #4
RMSe17
Member
 
Registered: Jul 2004
Posts: 31

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:15 PM.

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