- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: get the user list whose primary group is given...
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
07-04-2006 12:20 AM
07-04-2006 12:20 AM
get the user list whose primary group is given from HPUX box.
I want to get the username list whose primary group is given on HPUX.
I used following program to get the username
main()
{
int i=0;
struct group* grp;
grp = getgrnam("adm_system");
if(grp)
{
printf("%s\n",grp->gr_name);
printf("%s\n",grp->gr_passwd);
printf("%d\n",grp->gr_gid);
while (grp->gr_mem[i] !=NULL)
{
printf("%s\n",grp->gr_mem[i])
i++;
}
}
}
But it is displaying the user list whose secondary group is "adm_system" and also tried with getgrgid(), but it doesn't give the proper result.
Please help me to get the user list whose primary group is "adm_system"
Regards,
Prasant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:32 AM
07-04-2006 12:32 AM
Re: get the user list whose primary group is given from HPUX box.
Then with that in hand, I would a simple cat /etc/passwd | grep -i adm_system since in the etc/passwd file you will only find the primary group listed for each user.
Hope this help you out.
jaime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:34 AM
07-04-2006 12:34 AM
Re: get the user list whose primary group is given from HPUX box.
Then with that in hand, I would do a search for that ID in the group field of the passwd file and it will give you a list of the users that belong to adm-system.
Hope this help you out.
jaime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:42 AM
07-04-2006 12:42 AM
Re: get the user list whose primary group is given from HPUX box.
Thanks for replying to my query.
I think in NIS implementation, /etc/passwd will not give the proper answer.
If there is some direct system API, then it would be great.
Regards,
Prasant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:47 AM
07-04-2006 12:47 AM
Re: get the user list whose primary group is given from HPUX box.
Have you tried the logins command:
# logins -g
For more info see man logins.
Darrel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:56 AM
07-04-2006 12:56 AM
Re: get the user list whose primary group is given from HPUX box.
in your code change from the while statement on to scan the passwd database (does only depend on the entry in nsswitch.conf) something linke this:
setpwent()
while (pw = getpwent()) {
if (!strcmp(pw->pw_gid,grp->gr_gid)) {
do_my_output(...)
}
endpwent();
...
Read 'man getpwnam' and 'SEE ALSO's as well.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:57 AM
07-04-2006 12:57 AM
Re: get the user list whose primary group is given from HPUX box.
The best way to do will be using the ypcat group command and then scramble the data from there.
For a more detailed information, this thread might be able to help you out.
http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=27514
Regards,
Jaime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 12:58 AM
07-04-2006 12:58 AM
Re: get the user list whose primary group is given from HPUX box.
correction:
of cource the id's are numeric, so you don't need to compare strings:
setpwent();
while (pw = getpwent()) {
if (pw->pw_gid == grp->gr_gid) {
do_my_output(...)
}
endpwent();
...
mfG Peter