- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Adding multiple users - trusted systems
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2008 05:04 AM
тАО03-28-2008 05:04 AM
My experience with HP-UX is not very vast, but I have done some searching before I decided to post this question here. I need to add multiple (quite a lot) on many new servers (trusted systems). Is there a way, or some existing scripts that can accomplish this? Thank you.
P.S. My scripting techniques are at basic level.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2008 06:19 AM
тАО03-28-2008 06:19 AM
Re: Adding multiple users - trusted systems
cat userinfo |while read line
do
USER=$(echo $line|awk '{FS=":";print $1}')
PASS=$(echo $line|awk '{FS=":";print $2}')
USERID=$(echo $line|awk '{FS=":";print $3}')
GID=$(echo $line|awk '{FS=":";print $4}')
INFO=$(echo $line|awk '{FS=":";print $5}')
HOME=$(echo $line|awk '{FS=":";print $6}')
SHELL=$(echo $line|awk '{FS=":";print $7}')
echo "Adding $USER"
useradd -u $USERID -g $GID -s $SHELL -c "$INFO" -o -d $HOME -m -k /etc/skel $USER
/usr/sam/lbin/usermod.sam -p`echo "$PASS"` $USER
done
where the file userinfo whitch is just /etc/passwd looks like this:
dclifton:QNlEo8shV4aAs:281:300:Dawn Clifton:/ifas/admin:/bin/ksh
dcomegys:AiBlSJmBOE8GQ:282:300:Debbie Comegys:/ifas/admin:/bin/ksh
ddeakin:J093/LdkPWe4.:283:300:Deborah Deakin:/ifas/admin:/bin/ksh
deborahv:d4J3aJqNPmXlY:284:300:Deborah Vessey:/ifas/admin:/bin/ksh
debraa:l3i8xgyOEBVpE:285:300:Debra Aragon:/ifas/admin:/bin/ksh
deel:m6FKASCYkdCMM:286:300:Delores Leschinsky:/ifas/admin:/bin/ksh
dellis:05/iQ.n/Yx1YU:287:300:Dean M Ellis:/ifas/admin:/bin/ksh
dfotsch:i5bZyPUeYJNkk:288:300:Dan Fotsch:/ifas/admin:/bin/ksh
dgeisert:x8EA/6uTHJdYs:289:300:Donna Geisert:/ifas/admin:/bin/ksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2008 09:16 AM
тАО03-28-2008 09:16 AM
Re: Adding multiple users - trusted systems
I have a script that prompts for usernames, group, home dir, etc.. then use that to create a script full of usermod commands.
if you have a list here is a simplistic approach.
list.txt contents:
jdoe John Doe
bdoe Bill Doe
script contents:
uid=1000
ok=
cat list.txt|while read uname fname lname
do
while [[ $ok != "ok" ]]
do
if grep ":$uid:" /etc/passwd > /dev/null
then
(( uid = uid + 1 ))
else
ok=ok
fi
done
useradd -u $uid -c "$fname $lname" -m -s /usr/bin/ksh $uname
ok=
done
#end-of-script
This is about as simple as it gets.
looks for next unused uid over 1000, creates username and comment provided by list.txt then uses default /usr/bin/ksh shell and creates default home directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2008 03:14 PM
тАО03-28-2008 03:14 PM
SolutionYou already got lot of useful advice and scripts.
For a different reason, I wrote a Perl
script that does the same on
AIX, HP-UX, Linux, Tru64, and Solaris.
Even if you do not need it, you
can at least check which commands are used
and compare how it is done in different
OSes :)
http://www.circlingcycle.com.au/Unix-sources/add-batch-Unix-accounts.pl.txt
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2008 05:15 AM
тАО03-29-2008 05:15 AM