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:

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!

Without seeing the code, it will be difficult to answer...

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.

My script just contains the below statement to setting users password:

passwd $userName

Please post the whole script.