LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-12-2006, 09:39 AM   #1
JoeneB
LQ Newbie
 
Registered: Sep 2005
Location: The Netherlands
Distribution: Debian 3.1 "Sarge"
Posts: 14

Rep: Reputation: 0
Question 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

Last edited by JoeneB; 01-13-2006 at 06:55 AM.
 
Old 01-12-2006, 09:59 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
maybe not.

it checks for a pukka tty
for accepting the password.

useradd -p means "project" on my solaris
 
Old 01-12-2006, 10:41 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
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
 
Old 01-13-2006, 01:59 AM   #4
JoeneB
LQ Newbie
 
Registered: Sep 2005
Location: The Netherlands
Distribution: Debian 3.1 "Sarge"
Posts: 14

Original Poster
Rep: Reputation: 0
[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.
It helped alot. I'm confident the script will now be doing what I want it to do
Tnx again.

Last edited by JoeneB; 01-13-2006 at 06:54 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
bash - how to take input as a variable? trees Linux - General 1 02-19-2004 04:09 PM
my mouse input is takes as keyboard input in BASH e1000 Slackware 5 12-08-2003 03:00 PM
how to execute mail command in a shellscript mema Programming 1 10-30-2003 02:58 AM
bash-script input aizkorri Programming 7 07-08-2003 06:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration