![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing root group to group from other | mjkroner | SUN Solaris | 4 | 03-05-2009 04:25 AM |
| Monkcast #12: IBM HW group OEMs Solaris to chagrin of SW group & a ... - ZDNet.com bl | iBot | UNIX and Linux RSS News | 0 | 08-17-2007 04:30 PM |
| entry in /etc/group too long - problem using sudo with %group | poli | SUN Solaris | 4 | 12-21-2004 09:50 AM |
| AIX Unix.. number of users on system in a particular group | afiore | UNIX for Advanced & Expert Users | 1 | 06-26-2003 11:19 AM |
| NIS group vs local group | vjsony | UNIX for Dummies Questions & Answers | 3 | 05-19-2003 09:54 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
retrieving all group names with a given group number
hi,
which Unix/C function can i use to retrieve all group names with a particular group id? The following C code prints out the group id number of a particular group name: ------------------------------------------------------------------------ #include <stdio.h> #include <grp.h> int main(int argc, char * argv[]){ struct group * info; char ** members; int i=1; if(argc < 2){ fprintf(stderr, "usage: %s groupname\n", argv[0]); exit(-1); } info = getgrnam(argv[1]); if(info == NULL){ printf("%s: no such group\n", argv[1]); } else{ printf("group name: %s\n", info -> gr_name); printf("group id number: %d\n", info -> gr_gid); } } ------------------------------------------------------------------ % a.out vulcan1 group name: vulcan1 group id number: 15100 % a.out vulcan2 group name: vulcan2 group id number: 15100 % a.out vulcan3 group name: vulcan3 group id number: 15100 /////////////////////////////////////////////////// I'm looking for a C function that returns "vulcan1", "vulcan2", and "vulcan3" when I pass in the group id of 15100 (there are only 3 groups with group id of 15100). Thanks --Andrew |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|