no chance to input passwd when create new user in loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting no chance to input passwd when create new user in loop
# 1  
Old 01-16-2012
no chance to input passwd when create new user in loop

Hi Dears,

I have one script to create new users with information in one plain text file. This script will read all lines in the file and create one users for one line.

Sample file:
#action;login,full name title,expire date,project
+;gmwen,Bruce Wen QA,04/01/2012,BT
+;xxdeng,Shown Deng DEV,04/01/2012,BT
+;thli,Angela Li QA,04/01/2012,BT
+;xinhuang3,Jason Huang DEV,04/01/2012,BT

+ means to create.

After executing useradd command, I will set password for user with passwd command. Normally, it should prompt for password twice. But my script does not give me chance to enter password and just print below error to me:
HTML Code:
Changing password for user gmwen.
New UNIX password: BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password: Sorry, passwords do not match.
New UNIX password: BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password: New UNIX password: passwd: Authentication information cannot be recovered
In addition, subsequent users cannot be created because the script exits due to above error.

Bash version:
GNU bash, version 3.2.25(1)-release-(x86_64-redhat-linux-gnu)
on Red Hat 5.4

However, for bash version
GNU bash, version 3.00.16(1)-release-(sparc-sun-solaris2.10)
, it works well on Solaris OS.

Anybody can help me out of this trouble? Thanks!
# 2  
Old 01-16-2012
Without seeing the code, it will be difficult to answer...
# 3  
Old 01-16-2012
You will probably need to do this in two stages:
1) Read the parameter file and use it to write a shell script file containing alternate "useradd" and "passwd" commands. Make the file executable.
2) Run the new script file.

The original issue is no doubt that the main script and the passwd command are both reading from STDIN. Thus the passwd command reads characters from the parameter file. Note: This method is not suitable for setting passwords in a script because of the way the passwd command does not tolerate typeahead.
# 4  
Old 01-16-2012
Quote:
Originally Posted by vbe
Without seeing the code, it will be difficult to answer...
My script just contains the below statement to setting users password:
Code:
passwd $userName

# 5  
Old 01-17-2012
Please post the whole script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Would like to check user input for letters within a loop

Hi All, #!/bin/bash #Just trying to check if letters are in the user input. Any tips? # I have tried regexp and using 0-9 etc, i cannot get this to work either in just an if statement or while in a loop. echo "Please pick a number" read num if ; then echo "Please enter a number"... (7 Replies)
Discussion started by: jvezinat
7 Replies

2. Shell Programming and Scripting

Automaticaly create function based off user input

I am trying to create a bash script that will create new function by using the user input. The below will create the necessary files in the correct format, however when it comes to the # create function I am at a loss. If the name entered was NEWNAME and the genes were GENE1,GENE2 then two files... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

Loop breaks on yes/no user input

I have a shell script, and its pretty much done, I decided to add a loop that ends or continues depending on user input. like "would you like to continue?" and if I hit y or yes it will run the loop again until I hit n or no and breaks out of the loop. To be hones I didn't think I needed to add... (2 Replies)
Discussion started by: Demon_Jester
2 Replies

4. Shell Programming and Scripting

create an array which can store the strings from the user input in shell script

I want to create an array which can store the strings from the user input in shell script . example :- I want to store the 5 fruits name in a single array which the user provides . (1 Reply)
Discussion started by: Pkast
1 Replies

5. Shell Programming and Scripting

matching user input to a text file loop?

until do read -p "Invalid cars. Try againa" cars1 done Ok i have the above code, im getting users input and if it doesnt match in the file the user has to try again untill its correct But when i run this it gives me an error saying ./Cars.bash: line 43: (2 Replies)
Discussion started by: gangsta
2 Replies

6. Shell Programming and Scripting

How to automatically create variables from user input in ksh?

I need some help to write a ksh script. My code so far (pretty bad, sorry): #! /bin/ksh echo "Calculate average" UserDecision=y while test $UserDecision = y do echo "Enter a number: " read Number1 echo "Enter a number: " read Number2 echo "Do you want to enter another number?... (2 Replies)
Discussion started by: johnagar
2 Replies

7. Shell Programming and Scripting

every time user input create array perl

Hi, How to create array every time user input and store user input and display all array print " Enter input " my @input = split(' ', $input) chmop($input = <STDIN>; foreach ($input) { @array= @input; } print @array"\n"; (1 Reply)
Discussion started by: guidely
1 Replies

8. Shell Programming and Scripting

Create a multi user input form

Hi All, Please ignore if terminology used is incorrect as I am new to Unix. I want to create a Multi user input form which looks something like this: ABCD TOOL Logged User: abcd12 ... (4 Replies)
Discussion started by: vidhu0007
4 Replies

9. UNIX for Dummies Questions & Answers

Getting user input from inside a while loop?

I'm new to BASH and i'm trying to create a script which is simply put a large find and replace file. This is what I have so far N=0 while read LINE ; do N=$((N+1)) sed 's/'$2'/'$3'/g' $LINE > .temp echo "Changes to file $N = $LINE" echo 'The following changes... (5 Replies)
Discussion started by: Azumandious
5 Replies

10. Shell Programming and Scripting

Loop until user input is correct

Hello, i know how to retrieve a user input (read), and how to manage the different options (case statement). But... could anybody show me a script that, if the user option is incorrect, don't allow to continue the excution, i.e., if the value entered is not 1 or 2, the script shows a question. ... (2 Replies)
Discussion started by: aristegui
2 Replies
Login or Register to Ask a Question