GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Add NIS user script
Operating System - HP-UX
1847420
Members
2739
Online
110264
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-04-2002 09:20 AM
10-04-2002 09:20 AM
Add NIS user script
I would add a user through SAM, Add User, Add NIS user, but it doesn't create home directories unlike adding a local user.
So I need some guidance with writing a script to add a user to the NIS passwd.nis file, want to create a home directory for that user, and then copy some files into it.
Please tell me how to go about doing this. Case statements? If statements.. I am so confused.
Thanks...Angie
So I need some guidance with writing a script to add a user to the NIS passwd.nis file, want to create a home directory for that user, and then copy some files into it.
Please tell me how to go about doing this. Case statements? If statements.. I am so confused.
Thanks...Angie
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2002 09:54 AM
10-04-2002 09:54 AM
Re: Add NIS user script
This is a tricky problem because it greatly depends upon your environment. Typically, SAM can create a home directory on the NIS master server but generally you want a home directory elsewhere or maybe on multiple hosts. The most typical configuration is that the home directories are automounted and NIS maintains the automounter maps. In that scenario, no matter where a user logs in, his home directory is magically mounted although it might actually reside on a node far, far away.
You could script a remsh to a remote host to create the home directory.
You could script a remsh to a remote host to create the home directory.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2002 10:16 AM
10-04-2002 10:16 AM
Re: Add NIS user script
Ok well the home directory is going to be on an NFS mount directory.
So I need help getting started on writing the script... like I am new to script writing anything real complex. Just need guidance on getting started.
Thx..Angie
So I need help getting started on writing the script... like I am new to script writing anything real complex. Just need guidance on getting started.
Thx..Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2002 11:23 AM
10-04-2002 11:23 AM
Re: Add NIS user script
First, you need to change your logic, specially since your new.
Instead of having a user added to NIS from your scripts maintain SAM for this purpose, and make a script to deal with home directories.
If your using an automounter, then the problem is a bit more complex, but similar enough. I'll assume your using automounter and auto.home for users in my example. For basics though, remember a script is top down as with typing the commands manually.
#!/bin/sh
##########
echo "enter a user to make a home for"
read NEWUSR
TST=`grep $NEWUSR /etc/passwd|awk -F: '{print $1}'`
# Making sure there is such a user
if [ "${TST}x" = "x" ] ; then
echo "No such user $TST"
exit 1
elif [ "${TST}" = "NEWUSR" ] ; then
echo "Have user $TXT, going to process"
else
echo "unknown error. exiting"
fi# Have the user, so make the stuff...
GRP=`grep $NEWUSR /etc/passwd|awk -F: '{print $3}'`
#using GID is same as group name, and this is much easier
echo "$NEWUSR hostname:/export/$NEWUSR" >>/etc/auto.home
mkdir /export/$NEWUSR
chmod 755 /export/$NEWUSR
cp -p /etc/skel/.??* /export/$NEWUSR
chown -R $NEWUSR:$GRP /export/$NEWUSR
cd /var/yp
make auto.home
Of course directories dont match yours, and Im sure you need to make lots of modifications, you may be using ypmake instead of make, etc.. The example is to show basics in scripting. For info on the commands and routines in shells type
% man csh
% man sh
% man ksh
Man pages are really our friends, just tend to be dry at times.
Regards,
Shannon
Instead of having a user added to NIS from your scripts maintain SAM for this purpose, and make a script to deal with home directories.
If your using an automounter, then the problem is a bit more complex, but similar enough. I'll assume your using automounter and auto.home for users in my example. For basics though, remember a script is top down as with typing the commands manually.
#!/bin/sh
##########
echo "enter a user to make a home for"
read NEWUSR
TST=`grep $NEWUSR /etc/passwd|awk -F: '{print $1}'`
# Making sure there is such a user
if [ "${TST}x" = "x" ] ; then
echo "No such user $TST"
exit 1
elif [ "${TST}" = "NEWUSR" ] ; then
echo "Have user $TXT, going to process"
else
echo "unknown error. exiting"
fi# Have the user, so make the stuff...
GRP=`grep $NEWUSR /etc/passwd|awk -F: '{print $3}'`
#using GID is same as group name, and this is much easier
echo "$NEWUSR hostname:/export/$NEWUSR" >>/etc/auto.home
mkdir /export/$NEWUSR
chmod 755 /export/$NEWUSR
cp -p /etc/skel/.??* /export/$NEWUSR
chown -R $NEWUSR:$GRP /export/$NEWUSR
cd /var/yp
make auto.home
Of course directories dont match yours, and Im sure you need to make lots of modifications, you may be using ypmake instead of make, etc.. The example is to show basics in scripting. For info on the commands and routines in shells type
% man csh
% man sh
% man ksh
Man pages are really our friends, just tend to be dry at times.
Regards,
Shannon
Microsoft. When do you want a virus today?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP