Operating System - HP-UX
1848686 Members
7740 Online
104035 Solutions
New Discussion

Re: Script for Creating Users on Multiple system in ons go!!!

 
Saurabh Rawat
Advisor

Script for Creating Users on Multiple system in ons go!!!

Hi All,

Can you ppl suggest me a Script for creating user on multiple system of HP_UX, in which it has to include all basic attributes such as shell, GID and UID etc.
Insanity is often the logic of mind overtasked!!!
2 REPLIES 2
Apai
Occasional Advisor

Re: Script for Creating Users on Multiple system in ons go!!!

Hi Saurabh Rawat,

Maybe u can do this,

1. Put all username in file /def.txt

2. create new file in with below input.

#!/bin/sh
for USER in `cat /home/abc/def.txt`
do
echo $USER
useradd -m $USER
passwd -d $USER
passwd -f $USER
done

3. chmod u+x <script name> and run the script.

Hav fun!
Rasheed Tamton
Honored Contributor

Re: Script for Creating Users on Multiple system in ons go!!!

Hi Saurabh,

Make a text file as below containing all the user attributes

saurabhr 245 16 /home/saurabhr /usr/bin/sh
rasheedt 246 16 /home/rashedt /usr/bin/ksh

cat userlist | while read un uid gid dir shell
do
echo $un $uid $gid $dir $shell
useradd -u $uid -g $gid -d $dir -s $shell -m $un
done

(un = username, uid = user id, gid = group id, dir=home dir, shell=default shell for the user)

The group id should pre-exist on the systems.

For multiple systems, you should make one system trusted and trigger the above script from one central server. You could make a filename with list of hostnames and run it with remsh or ssh according to your setup.