February 2012
Intermediate to advanced
1184 pages
37h 17m
English
getgrent setgrent endgrent
These routines iterate through your /etc/group file (or maybe someone else’s
/etc/group file, if it’s coming
from a server somewhere). The return value from getgrent in list context is:
# 0 1 2 3 ($name, $passwd, $gid, $members) = getgrent();
where $members contains a
space-separated list of the login names of the members of the group. To
set up a hash for translating group names to GIDs, say this:
while (($name, $passwd, $gid) = getgrent()) {
$gid{$name} = $gid;
}In scalar context, getgrent
returns only the group name. The standard User::grent module supports a by-name interface to this function. See
getgrent(3).
Read now
Unlock full access