- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Adding Multiple Users using a script on a Trusted ...
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
Forums
Discussions
Discussions
Discussions
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
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-15-2005 07:10 PM
03-15-2005 07:10 PM
I have got multiple hpus servers on those I need to create nearly 20 new users. Being this is a big talk I would like to use a script for this.
I have the following text files from where I need the inputs to be taken for the user creation. the files are.
logid ( this is the required login ID )
username ( This is the user description required.This is in the format of "Firstname LastName" )
I understand the useradd command will take a unique ID and since i am not using an input file for the same.
I started writing the script as follwos. Dont laugh at me..Im very bad in scripting.Sorry....
#!/usr/bin/sh
#This script will add users taking input from the files logid & username present in the current directory.
clear
echo "\n\n\n"
#groupadd dbuser
for logid in `cat ./logid`
do
for username in `cat ./username`
do
#useradd -c "$username" -g dbuser -m -s /usr/bin/ksh -k /etc/skel -d /home/$logid db$logid
echo "Created user $username\n"
done
done
I hashed the groupadd and useradd commands before actually executing the same. I understand that my looping is not proper.
Can anyone correct my script or recommand a better & easier method to achieve my goal.
Thanks a million in advance.
Regards,
Syam
Solved! Go to Solution.
- Tags:
- useradd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2005 07:40 PM
03-15-2005 07:40 PM
SolutionI would first combine the logid and username file into format:
logid FirstName LastName
then
#!/usr/bin/sh
#groupadd dbuser
#read all the data in the file user.dat
while read data
do
#split the fields up
#first field
logid=`echo $data | cut -d' ' -f1`
#second field onwards
username=`echo $data | cut -d' ' -f2-`
#useradd -c "$username" -g dbuser -m -s /usr/bin/ksh -k /etc/skel -d /home/$logid db$logid
echo "Created user $username"
done < user.dat
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2005 08:06 PM
03-15-2005 08:06 PM
Re: Adding Multiple Users using a script on a Trusted System
Thanks a lot...But will this work on trusted system? The passwords are stored in TCB database.
Also I wanted the passwords also to be changed with this to a specified one Else.
Else this script wont do the purpose since I have to go to every machine to change the passwords.
Thanks once again.
regards,
Syam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2005 08:17 PM
03-15-2005 08:17 PM
Re: Adding Multiple Users using a script on a Trusted System
the second part of the question is a bit more tricky (I think).
According to man useradd:
"If the system is in trusted mode, useradd returns a random password to stdout: the new login is still locked until the passwd command is invoked."
So the problem is to change the password, which I think would be best done using expect.This will then allow you to chnage the password and unlock the account at the same time.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2005 10:38 PM
03-15-2005 10:38 PM
Re: Adding Multiple Users using a script on a Trusted System
Can Anyone again explain me how to overcome the problem of changing password using the script on the trusted system.
Regards,
Syam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2005 06:12 PM
03-19-2005 06:12 PM
Re: Adding Multiple Users using a script on a Trusted System
I modified my script again as follows and it is now able to server my purpose. Thanks for all.
############################################################
#!/usr/bin/sh
groupadd dbuser
rm -f passwords.dat
#read all the data in the file user.dat
while read data
do
#split the fields up
#first field
logid=`echo $data | cut -d' ' -f1`
#second field onwards
username=`echo $data | cut -d' ' -f2-`
useradd -c "$username" -g dbuser -m -s /usr/bin/ksh -k /etc/skel -d /home/db$logid db$logid
/usr/lbin/modprpw -x db$logid >> passwords.dat
echo "Created user $username"
done < user.dat
cat passwords.dat|cut -f2 -d"=">passwords.txt
rm -f passwords.dat
########################################################
The above script stored the initial passwords in a txt file called passwords.txt. I only need to do cat passwords.txt and copy paste to excel.
My Problem is solved.
Closing this thread. Thanks all who replied.
regards,
Syam
- Tags:
- modprpw