HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: KSH/SAM Question
Operating System - HP-UX
1834403
Members
2637
Online
110067
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
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
04-21-2003 12:41 PM
04-21-2003 12:41 PM
KSH/SAM Question
I have created a custom script for SAM in order to add users to multiple servers with a primary group and a supplementary group in the same script. I am having trouble adding the user to the supplementary group. This is what I have so far:
#!/bin/ksh
echo "\n\n\nThis script should be used to add new grp user and grp user accounts with a home directory"
echo "shell. If this is not what you want to do enter 'Cntl C' to exit. \n"
REPLY=N
case `echo $REPLY` in
y|Y|yes|Yes|YES ) echo "What is the user id ?? ====> \c"
read uname
echo "What is the new users name ?? =====> \c"
read username
echo "Office Location ?? =====> \c"
read officeloc
echo "What is the Password ?? =====> \c"
read passwd
echo "Office Phone ?? =====> \c"
read officephone ;;
n|N|no|No|NO ) echo "What is the user id ?? ====> \c"
read uname
echo "What is the new users name ?? =====> \c"
read username
echo "Office Location ?? =====> \c"
read officeloc
echo "Office Phone ?? =====> \c"
read officephone
echo "What is the Password ?? =====> \c"
read passwd
echo "Do you wish to add user to servername for group and group testing ?? =====> \c"
read servername_BOTH
if [[ $servername_BOTH = @(N|n|NO|No|no) ]]
then
echo "Do you wish to add the user to servername for group testing ?? =====> \c"
read servername_group
fi
if [[ $servername_group = @(N|n|NO|No|no) ]]
then
echo "Do you wish to add the user to servername for grp testing ?? =====> \c"
read servername_grp
fi ;;
esac
/usr/local/adduser/allsys "cat /etc/passwd | cut -d : -f 3" | sort -u -k 1n > /tmp/pass
UID=1500
while [ "$i" != "1" ]
do
grep $UID /tmp/pass > /dev/null
KEY=`echo $?`
if [ "$KEY" = "1" ]
then
if [[ $servername_BOTH = @(Y|y|YES|Yes|yes) ]]
then
echo "Adding $uname to servername for group testing"
remsh servername -n "/usr/sam/lbin/useradd.sam -u $UID -g group -s /usr/bin/sh -p '$(/usr/local/bin/Encrypt $passwd)' -d /home/$u -c '$username
,$officeloc,$officephone' $uname ; /usr/sam/lbin/upusrfiles -r $uname"
sleep 5 ;
echo "Adding $uname to servername for group testing"
remsh servername -n "/usr/sam/lbin/get_gr_mems |/usr/sam/lbin/grpusrs -m -l"$uname" group"
sleep 5
fi
i=1
else
UID=`echo $(( $UID+1 ))`
fi
done
I was thinking I might be able to use ("/usr/sam/lbin/grpusrs -m -l"$uname" group") and (/usr/sam/lbin/get_gr_mems group | /usr/bin/sort ???u) to get the current members of the group and concatenate them into the first process and add the new username. I am not sure how to redirect the group member???s output into the first command. Any suggestions on how to do this, or alternative methods would be greatly appreciated.
#!/bin/ksh
echo "\n\n\nThis script should be used to add new grp user and grp user accounts with a home directory"
echo "shell. If this is not what you want to do enter 'Cntl C' to exit. \n"
REPLY=N
case `echo $REPLY` in
y|Y|yes|Yes|YES ) echo "What is the user id ?? ====> \c"
read uname
echo "What is the new users name ?? =====> \c"
read username
echo "Office Location ?? =====> \c"
read officeloc
echo "What is the Password ?? =====> \c"
read passwd
echo "Office Phone ?? =====> \c"
read officephone ;;
n|N|no|No|NO ) echo "What is the user id ?? ====> \c"
read uname
echo "What is the new users name ?? =====> \c"
read username
echo "Office Location ?? =====> \c"
read officeloc
echo "Office Phone ?? =====> \c"
read officephone
echo "What is the Password ?? =====> \c"
read passwd
echo "Do you wish to add user to servername for group and group testing ?? =====> \c"
read servername_BOTH
if [[ $servername_BOTH = @(N|n|NO|No|no) ]]
then
echo "Do you wish to add the user to servername for group testing ?? =====> \c"
read servername_group
fi
if [[ $servername_group = @(N|n|NO|No|no) ]]
then
echo "Do you wish to add the user to servername for grp testing ?? =====> \c"
read servername_grp
fi ;;
esac
/usr/local/adduser/allsys "cat /etc/passwd | cut -d : -f 3" | sort -u -k 1n > /tmp/pass
UID=1500
while [ "$i" != "1" ]
do
grep $UID /tmp/pass > /dev/null
KEY=`echo $?`
if [ "$KEY" = "1" ]
then
if [[ $servername_BOTH = @(Y|y|YES|Yes|yes) ]]
then
echo "Adding $uname to servername for group testing"
remsh servername -n "/usr/sam/lbin/useradd.sam -u $UID -g group -s /usr/bin/sh -p '$(/usr/local/bin/Encrypt $passwd)' -d /home/$u -c '$username
,$officeloc,$officephone' $uname ; /usr/sam/lbin/upusrfiles -r $uname"
sleep 5 ;
echo "Adding $uname to servername for group testing"
remsh servername -n "/usr/sam/lbin/get_gr_mems |/usr/sam/lbin/grpusrs -m -l"$uname" group"
sleep 5
fi
i=1
else
UID=`echo $(( $UID+1 ))`
fi
done
I was thinking I might be able to use ("/usr/sam/lbin/grpusrs -m -l"$uname" group") and (/usr/sam/lbin/get_gr_mems group | /usr/bin/sort ???u) to get the current members of the group and concatenate them into the first process and add the new username. I am not sure how to redirect the group member???s output into the first command. Any suggestions on how to do this, or alternative methods would be greatly appreciated.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2003 01:37 PM
04-21-2003 01:37 PM
Re: KSH/SAM Question
I would suggest using usermod, man usermod, to modify users with the remsh:
usermod -G group -g group username
Where G is alternate group and g is primary group.
from man usermod:
-g group Specifies the integer group ID or character
string name of an existing group. This
redefines the primary group membership of the
new login.
-G group Specifies the integer group ID or character
string name of an existing group. This
redefines the supplemental group memberships
of the new login. Duplicates within group
with the -g and -G options are ignored.
usermod -G group -g group username
Where G is alternate group and g is primary group.
from man usermod:
-g group Specifies the integer group ID or character
string name of an existing group. This
redefines the primary group membership of the
new login.
-G group Specifies the integer group ID or character
string name of an existing group. This
redefines the supplemental group memberships
of the new login. Duplicates within group
with the -g and -G options are ignored.
If it has wheels or a skirt, you can't afford it.
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 2025 Hewlett Packard Enterprise Development LP