- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- useradd several users in a 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
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
04-30-2004 02:32 AM
04-30-2004 02:32 AM
Have a text file (see example in the bottom of the message).
How do I script it so I don't have to do it manually ?
====================
while `cat userlist`
do
useradd -u $3 -g users -c "$1" -d /home/$2 -m $2
==================
done
( I believe $1 will trip me here so I can't use space as a delimeter, because of first name and last name).
----------------
# cat userlist
Joe Smow jose214 345
Mike Jones mike123 346
San Kumar san233 347
...
...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 02:42 AM
04-30-2004 02:42 AM
Re: useradd several users in a script ?
Some of these names have middle initial. And there is more than 3 spaces between the full name(joe Smow) , username id(joe214), and uid(345).
=================
# cat userlist
Joe Smow joe214 345
Mike Jones mike123 346
San Kumar san233 347
Saml L. Jacks samu234 348
Jo S mike joe232 349
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 02:44 AM
04-30-2004 02:44 AM
Solutioncat userlist | while read NAME1 NAME2 XLOGIN XUID
do
useradd -u ${XUID} -g users -c "${NAME1} ${NAME2}" -d /home/${XLOGIN} -m ${XLOGIN}
done
The better answer would be to put the comment field (Full Names) LAST in each line because read assigns everything leftover to the last variable listed:
cat userlist | while read XLOGIN XUID NAME
do
useradd -u ${XUID} -g users -c "${NAME}" -d /home/${XLOGIN} -m ${XLOGIN}
done
Rather than rearranging the order of field in your userlist, you could use awk to do the same thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 02:55 AM
04-30-2004 02:55 AM
Re: useradd several users in a script ?
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=29109
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2004 04:51 AM
04-30-2004 04:51 AM
Re: useradd several users in a script ?
I like your method of using awk to put the comment line in the end. That works great. Good point!! and Thanks a bunch.I used that and it works.
Cheryl,
I got some good hints (especially Sridhar suggestions) from the link you provided but Clay method gave me exactly what I wanted.
Appreciate it Clay, cheryl.