My task is to write a perl program that will read in names/passwords from a text file and from that create user accounts and all sorts of stuff. Now I have been able to do the "stuff" and the only part giving me jip is how to overcome creating the password for the user after useradd. Using passwd on its own requires interaction to type in the password twice to confirm, and this is the part im not sure on.
#Create the user account and add a password system ("/usr/sbin/useradd -m $user"); system ("echo $userpass | --stdin passwd $user");
This gives me the error:
sh: -c: line 2: syntax error near unexpected token `|'
sh: -c: line 2: ` | --stdin passwd moose'
moose being the username I used :mrgreen:
It was suggested that when I had copied/pasted from a file that the char's where being corrupted so I typed the whole thing out again, to no avail.
I have investigated the possibility of using the unix_md5_crypt module to create my own encrypted passwords and use the -p tag in the useradd function but as I wont be able to install any modules on the computers this is pretty much void.
Using -p in the useradd will only add a plaintext password to the shadow file, which is useless too.
Any pointers are appreciated as I spent too long yesturday googling :-|