LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-18-2003, 12:25 PM   #1
mystykmax
LQ Newbie
 
Registered: Feb 2003
Posts: 2

Rep: Reputation: 0
bash script for passwd


ok, this will seem ridiculous at first, but hear me out...hehe
I want to have a script that adds users, sets paths in .bashrc and all that...I've got that working great (in the pasted in script below)..HOWEVER, I cannot seem to set the passwd...I want this script to just set the users up with one generic passwd, which I will then go in and change...any ideas what I am doing wrong?

#!/bin/bash

cat names | while read -a userinfo
do
#userinfo[1] = gecos info while userinfo[0] = username
/usr/sbin/useradd -c ${userinfo[1]} ${userinfo[0]}
#now make their password

echo "${userinfo[0]} added."

/bin/mkdir /home/"${userinfo[0]}"/www
/bin/mkdir /home/"${userinfo[0]}"/bin

chown ${userinfo[0]} /home/"${userinfo[0]}"/www
chown ${userinfo[0]} /home/"${userinfo[0]}"/bin

chgrp ${userinfo[0]} /home/"${userinfo[0]}"/www
chgrp ${userinfo[0]} /home/"${userinfo[0]}"/bin

echo 'PATH=$PATH:/home/'"${userinfo[0]}"'/bin' >> /home/"${userinfo[0]}"/.bashrc
echo "export PATH" >> /home/"${userinfo[0]}"/.bashrc

#try to add password
passwd "${userinfo[0]}" >> passwdoutput
until grep "New" passwdoutput
do
sleep 1
done

echo "test\r"

until grep "Retype" passwdoutput
do
sleep 1
done
echo "test\r"

done
 
Old 02-19-2003, 03:40 PM   #2
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
You can use the comand newusers to do that. You will need a file with the structure:

accountassword:UID:GID:GECOS:directory:shell

Then:

# newusers <filename>

Using that with /etc/skel, you can do that easily ...
 
Old 02-20-2003, 12:33 AM   #3
verigoth
Member
 
Registered: May 2002
Posts: 179

Rep: Reputation: Disabled
just out of curiousity, is this for an e-mail server? if so, you could elimante having actual users by using cyrus' mail servers

verigoth
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete group users from /etc/passwd SCRIPT wesleywest Linux - General 5 03-08-2005 09:59 AM
Looking for addusesr&passwd shell script szklanka Programming 1 02-22-2005 08:37 PM
Build Passwd for personal access script, I want to solution. somphob Linux - General 2 08-01-2004 04:25 PM
need a script that can change the passwd bahadur Linux - Security 1 07-09-2004 05:07 AM
Bash script to edit passwd without Root password? NetFlash Linux - Newbie 2 11-29-2003 04:22 PM

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

All times are GMT -5. The time now is 10:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration