LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-24-2010, 12:15 PM   #1
kopper27
Member
 
Registered: Nov 2009
Posts: 147

Rep: Reputation: 16
Users script


hi guys

I have pretty simple basic script well 2 scripts to create users

it basically reads an usersinfo file with this structure

FirstName and Last Names - CompanyName LoginID UID

Code:
Charlie Mareuz Yander - CompanyName logind 600
Ana Benz Squel - BAC CompanyName loginid 601
and uses an useradd command to just create the user

Code:
#!/bin/bash
while read -r l1 l2 l3 l4 l5 l6 l7
do
useradd -c "$l1 $l2 $l3 $l4 $l5" $l6 -u $l7
done <usersinfo
cat /etc/passwd
After that manually I have to set the password for every user
so for 4 users I have to use passwd loginID 4 times

I need a way to add to my script how to read passwords in that same file (usersinfo) and script that instead of doing manually

I've tried but since the password is asked twice I don't know how to script that

would be like

Code:
#!/bin/bash
while read -r l1 l2 l3 l4 l5 l6 l7
do
useradd -c "$l1 $l2 $l3 $l4 $l5" $l6 -u $l7
passwd $16
???? don't know how to read from the file the password I want for this user
done <usersinfo
cat /etc/passwd
any idea?

thanks a lot
 
Old 02-24-2010, 12:31 PM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
passwd(1) offers the option --stdin to read the password from stdin:
Code:
echo $password | passwd --stdin $l6
 
Old 02-24-2010, 01:19 PM   #3
kopper27
Member
 
Registered: Nov 2009
Posts: 147

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by irmin View Post
passwd(1) offers the option --stdin to read the password from stdin:
Code:
echo $password | passwd --stdin $l6

thanks a lot that's all I needed
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to Auto-add Domain Users to Workstation Power Users Group doesn't work avinash.rao Ubuntu 0 08-22-2009 04:57 AM
Script to add a secondary group to all users except system default users Tekken Linux - Server 5 06-29-2009 04:02 PM
create users using script polis Linux - General 1 05-18-2004 08:19 AM
freebsd new users script evilchild Programming 0 12-30-2003 10:57 PM
E-Mail notification to users via SMS (gateway script ok, but notification script?!?) Riku2015 Linux - Networking 10 03-08-2002 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:18 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration