1832351 Members
2591 Online
110041 Solutions
New Discussion

Adding Multiple Users

 
Evans Kelley
Occasional Advisor

Adding Multiple Users

Actually this is a two part question, but I would like to get some ideas of scripts in place.
We currently already have NIS and NIS+ (scary hu?) in two different environments.
All our 10.20 systems are on NIS the 11.00 systems are on NIS+. We have been asked to add roughly 700 users to BOTH environments. I have already successfully added the 700 users to the passwd on NIS, we are currently working on a way to add in NIS+ but what I need to do in the mean time is come up with some scripts that will ease the pain. What I need is a script (very new to scripting) that I can give a list of users, then have it copy a default directory then chown on the permissions then move onto the next id in the list. I am sure this is very easy for some of you but would appreciate all of your input and ideas. Maybe someone else has had to do this as well.

Thanks for your time.
ekelley
2 REPLIES 2
John Poff
Honored Contributor

Re: Adding Multiple Users

Hi,

Something like this?

#!/bin/sh

# add_users.sh

while read USER
do
echo "Adding user $USER"
done



Create a file named add_users.sh with the lines listed above, and do a chmod +x add_users.sh to make the script executable.

Now, create a file with a list of user names, call it user.dat. You can execute your new script like this:

./add_users.sh

Inside of the do-loop, where the 'echo' statement is, you can add lines that will operate with the $USER variable as needed. You can add lines to cp, chmod, etc. as needed.

This little snippet of code should be enough to get you started.

Have fun!

JP
Steven E. Protter
Exalted Contributor

Re: Adding Multiple Users

You can take the /etc/passwd file on the master NIS server that has the 700 users and write a script that uses awk to get the username out and input it to the useradd command on the 11.00 NIS+ server.

Rough example.

newuser=`cat /etc/passwd | awk {print $1}`

then the value in $newuser is the input to useradd

useradd $newuser

Then its NIS push time.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com