accepting passwords in shell programming


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting accepting passwords in shell programming
# 1  
Old 08-12-2011
accepting passwords in shell programming

how do i accept a password like input through keyboard using shell script?
i dont know the command for doing so.
# 2  
Old 08-12-2011
You'd like to hide the input when its typed? With the stty command you can change the terminal settings.
Code:
echo "Enter password:"
savestty=$(stty -g)
stty -echo 
read input_passwort
stty "$savestty"

# 3  
Old 08-12-2011
cero, is there a need for stty -g? stty -echo before the read and stty echo after, should work fine, I believe.
# 4  
Old 08-12-2011
Bash and zsh (and I think ksh93) have -s option for "read" command to get input from a terminal without echoing.
# 5  
Old 08-12-2011
@g.pi: I just feel save to have all settings saved and when messing around with stty I usually save the settings when the script starts and reset them in a trap to have a working terminal in case the script gets interrupted while reading the password or under any other changed stty setting.
But if the shell allows read's -s option sounds less dangerous.
This User Gave Thanks to cero For This Post:
# 6  
Old 08-12-2011
@yazu, FYI - not ksh93. At least, not the version on Ubuntu:
Quote:
Version JM 93t+ 2009-05-01
This is what man says about the -s option:
Quote:
If the -s option is present, the input will be saved as a command in the history file.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command not accepting variable in shell script

I am using a shell script in fedora linux. While calling to the shell I am also passing an argument (var1=0.77) like shown below sh gossip.sh var1=0.77 in the shell following command is written (which doesn't work) sed - i -e 's@prob=@prob="$var1";//@g' file.txt Actually i want the... (7 Replies)
Discussion started by: Fakhar Hassan
7 Replies

2. Shell Programming and Scripting

Shell script to ssh and change the passwords

Hi All, I am trying to create a script with the help of while and expect loop to do the following: 1. script will pick up the servers one by one from server_list file and will do ssh to it. 2. for each server it will change the password of user test1. 3. script should also provide logs for... (1 Reply)
Discussion started by: omkar.jadhav
1 Replies

3. UNIX for Advanced & Expert Users

When did UNIX start using encrypted passwords, and not displaying passwords when you type them in?

I've been using various versions of UNIX and Linux since 1993, and I've never run across one that showed your password as you type it in when you log in, or one that stored passwords in plain text rather than encrypted. I'm writing a script for work for a security audit, and two of the... (5 Replies)
Discussion started by: Anne Neville
5 Replies

4. UNIX for Dummies Questions & Answers

Change user passwords using shell script

Hi, I want to change the password of unix users on a number of servers.My plan was to ssh to all the servers in a shell script and use the passwd command. I tried to do so but everytime i run it i get this error. ssh -x -n -l user1 host passwd Changing password for "user1" 3004-709 Error... (3 Replies)
Discussion started by: poojabhat
3 Replies

5. Shell Programming and Scripting

Help with shell scripting for accepting .csv files as CLA

I want to automate test script on shell scripting. There are 2 .csv files named account.csv and balance.csv.These files needs to passed as command line arguments and the following logic needs to applied further. Any account with a balance that was due before Oct 23, 2007 has an overdue... (2 Replies)
Discussion started by: coolguy123
2 Replies

6. UNIX for Dummies Questions & Answers

A shell script or software for generating random passwords

Hi, Is there an shell script/batch file to genarate random passwords which expires after a stipulated time period? Please suggest a software which does this for AIX and windows both else. Thanks. (5 Replies)
Discussion started by: dwiravi
5 Replies

7. UNIX for Dummies Questions & Answers

A shell script or any software to genarate random passwords

Hi, Is there a shell script or any software to genarate random passwords and the passwords expire automatically after a stipulated time period. Please suggest. (2 Replies)
Discussion started by: dwiravi
2 Replies

8. Shell Programming and Scripting

Accepting user input in c shell

i need to accept the user input in my c shell script before executing next command. i have the following code which ask for user input, but does not store this value. set req echo " Enter your input(Y/N)?" read req if (req = Y) echo " print $req" else echo " print $req" ... (3 Replies)
Discussion started by: skumar11
3 Replies

9. Shell Programming and Scripting

Accepting user input in Bourne shell and using sed

He guys. Basically I want to make a script that can add, delete and view stuff in a external file called config.txt. I can open it up in Joe but im not sure how to read in the user input or using commands automatically in joe to edit, save then quit. Problem area below: 1) echo "Add... (1 Reply)
Discussion started by: Pits
1 Replies
Login or Register to Ask a Question