LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Bash Shellscript automating command input (http://www.linuxquestions.org/questions/programming-9/bash-shellscript-automating-command-input-402473/)

JoeneB 01-12-2006 09:39 AM

Bash Shellscript automating command input [solved]
 
Hi there,

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 :)

bigearsbilly 01-12-2006 09:59 AM

maybe not.

it checks for a pukka tty
for accepting the password.

useradd -p means "project" on my solaris

marozsas 01-12-2006 10:41 AM

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

JoeneB 01-13-2006 01:59 AM

[solved, thanks :)]
 
Quote:

Originally Posted by marozsas
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


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 :)
Tnx again.


All times are GMT -5. The time now is 07:41 PM.