- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help - script for adding users
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
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
тАО08-14-2002 03:57 PM
тАО08-14-2002 03:57 PM
I am very new to writing scripts and have read a bit on case statements and half way understand them.
So I would prefer it to be written with the case statement if that can be done.
Can someone please help me?
Thx..Angie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2002 04:04 PM
тАО08-14-2002 04:04 PM
Re: Need help - script for adding users
Thx..Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2002 06:12 PM
тАО08-14-2002 06:12 PM
Re: Need help - script for adding users
You will need to input the information about the logins somehow. Let's say you have an input file in this format
#cat user_input
user1 - 5000 - User1, some info - 20 - /usr/bin/ksh
user2 - 5001 - User2, some info - 20 - /sbin/sh
user3 - 5002 - User3, some info - 20 - /sbin/csh
You can write a very simple script like this
#!/usr/bin/ksh
cat user_input |while read line
do
USER=$(echo $line|awk '{FS="-";print $1}')
UID=$(echo $line|awk '{FS="-";print $2}')
GECOS=$(echo $line|awk '{FS="-";print $3}')
GID=$(echo $line|awk '{FS="-";print $4}')
SHL=$(echo $line|awk '{FS="-";print $5}')
echo "Adding $USER"
useradd -u $UID -g $GID -s $SHL -c "$GECOS" -m -k /etc/skel $USER
passwd -df $USER
done
The above will force reset the passwords of the users so that when then login, it will prompt to chage their passwords.
It is a security risk. You can generate a an encrypted password and enter it into passwd file. You can search in the forums and find the ways of doing it. There are quite a number of threads on it.
I hope it can help you to start with.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 06:41 AM
тАО08-15-2002 06:41 AM
Re: Need help - script for adding users
This will be given to the help desk, this script. A new user will be setup by the helpdesk maybe once a week.
They need to then have a menu and choose from the menu the 'add user' or 'change user' or 'delete user'... options.
Then they will input the information at the various prompts about who they are adding (for example).
It should ask too what group they will be in (sales, engineering) and if they are in one of those groups, then it should use the group ID assigned to that group (like 20 or 30 or whatever).
I wonder if Case statements or If/then would work? I know nothing about awk so I wanted to avoid that. Please help...thx.Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 06:45 AM
тАО08-15-2002 06:45 AM
SolutionAs a general rule, 'case' statements are superior to 'if/else/if...' oscillations for three or more cases.
The code is generally faster to execute, smaller, and perhaps most importantly, easier for the human to read and maintain.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 06:47 AM
тАО08-15-2002 06:47 AM
Re: Need help - script for adding users
Man sam for details and note the "Restricted SAM" section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 06:52 AM
тАО08-15-2002 06:52 AM
Re: Need help - script for adding users
If you want to learn more about case and if statements try getting a copy of "Learning the Korn Shell" by O'Reilly.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 06:58 AM
тАО08-15-2002 06:58 AM
Re: Need help - script for adding users
Otherwise do you all agree that Case statements are better for something like this? And if it is better, please explain to me why.
Thanks..Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 07:52 AM
тАО08-15-2002 07:52 AM
Re: Need help - script for adding users
In almost all cases, readability is valued above pure efficiency.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 08:31 AM
тАО08-15-2002 08:31 AM
Re: Need help - script for adding users
Restricted SAM is a great idea.
I would not say "case" is the better statement than if-then-else as it is dependent on the function of the script, but it is the famous statement used in cases like this. If you are willing to write a script, then I would suggest that you write functions for each action and call them from the case statement. If there are a lot of cases, if-then-else can confuse you enough.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 09:36 AM
тАО08-15-2002 09:36 AM
Re: Need help - script for adding users
I have to agree with all the Guru???s. Restricted SAM is a great idea. Also, one more great idea is you might want to assign some points to these guys.
Thanks,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 09:40 AM
тАО08-15-2002 09:40 AM
Re: Need help - script for adding users
HTH
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 09:41 AM
тАО08-15-2002 09:41 AM
Re: Need help - script for adding users
I ended up being able to use the Restricted Sam (ran it by the boss) and set up a test account. This really relieved the pressure!
Angie