Bash Shellscript automating command input [solved]
I've tried search first but couldn't find an answer I was looking for. So here goes:
For testing pruposes I have to create multiple users at once. My thought was... shell scripting. Now I have managed to create a script that allows me to just give the amount of users I need and it will create them.
So when I say createuser.sh 10, 10 users will be created with the names "user1, user2,... user10".
These users however do not have passwords. When I try to use passwd <username> it ofcourse asks to input a password and verify this. The question here is, is there a way to let the script do this for me? So when user1 is created it will set its password to something like password1 without me typing it in?
I though maybe if I use chpasswd with a file where I have the usernames: passwords would work but I get the message it's missing the new password...
Using useradd <username> -p <password> didn't work either.
Now I'm pretty new at shell scripting and the use of linux.
I'm using Bash on Debian 3.1 Sarge. Any help and/or tips are greatly welcomed :)
it checks for a pukka tty
for accepting the password.
useradd -p means "project" on my solaris
The command mkpasswd from the package whois-4.7.5-3.rpm do the job.
This command creates a encrypted string which is compatible with /etc/shadow and useradd's p option.
$ useradd -p "`mkpasswd initialpassword`" user1
[solved, thanks :)]
It shows how big of a newbie I am... 'mkpasswd' ... never thought of that.
:D It helped alot. I'm confident the script will now be doing what I want it to do :)
|All times are GMT -5. The time now is 03:51 PM.|