- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Creating new user with script
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
тАО10-22-2006 05:49 PM
тАО10-22-2006 05:49 PM
Creating new user with script
I have one text file containing first field as user id and second field as passwd.I would like to write a script which will add the new users with this user id and password with out any interaction.(it should take the second field as the input for passwd command).Can anybody help in this?
Thanx in advance
Jerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2006 06:12 PM
тАО10-22-2006 06:12 PM
Re: Creating new user with script
user_account_name:encrypted_password
You will let the system to select UID and you will use default group id (otherwise, you can use -u UID -g GID in useradd command to define UID and GID):
#!/usr/bin/ksh
while read line
do
uname=`echo $line|cut -d":" -f1`
passwd=`echo $line|cut -d":" -f2`
useradd -m $uname
/usr/sam/lbin/usermod.sam -p $passwd
done < passwd.1
exit
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2006 06:18 PM
тАО10-22-2006 06:18 PM
Re: Creating new user with script
Thanx for your reply.
The password is not encripted.I perfer not to use usermod.sam because I need to do the same excercise on my linux file server also.Is there any common shell script which can do this?
Jerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2006 07:45 PM
тАО10-23-2006 07:45 PM
Re: Creating new user with script
this thread could help you:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=952123&admit=-682735245+1125402405698+28353475
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2006 12:13 AM
тАО10-24-2006 12:13 AM
Re: Creating new user with script
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2006 12:36 AM
тАО10-24-2006 12:36 AM
Re: Creating new user with script
If you want to put the password in on an HP box w/o the use of expect, you're stuck with usermod.sam or ueradd.sam. How you differentiate between Linux and HPUX is through a variable:
Os=$(uname -s)
[[ "${Os}" = "HP-UX" ]] && Useradd=/usr/sam/lbin/useradd.sam || \
Useradd=/usr/sbin/useradd
uid=1000
cat passwd.1 | while read user pwd
do
printf "%-8s %s\n" ${user} ${pwd}
${Useradd} -u ${uid} -g users -c "test user" -d /home/${user} \
-p ${pwd} -s /bin/ksh ${user}
mkdir -p -m 755 /home/${user}
cp /etc/skel/.[A-z]* /home/${user}
chown -R ${user}:users /home/${user}
uid=$((uid+1))
done
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2006 08:34 AM
тАО10-24-2006 08:34 AM
Re: Creating new user with script
Thanx for the reply. We have Holy Ramadan vacation here and not in a position to try out the option.I will try after the vaction and update you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2006 11:11 PM
тАО10-24-2006 11:11 PM
Re: Creating new user with script
You can try this for adding users:
while read username password
do
useradd [options] ${username}
done < your_file
Still thinking about how to automatically assign passwords to new user.