Chad Perrin wrote:
On Thu, Dec 21, 2006 at 08:05:05AM -0700, Tom Smith wrote:
Dr.Ruud wrote:
Chad Perrin schreef:
Of course, if you're going to call out of the Perl script to the id
utility, you may as well skip the Perl script entirely and just enter
this at the shell prompt:
id -Gn username
That depends on what OP needs to do with the result. It could be part of
a larger Perl script that is doing other stuff as well.
Yeah, it is part of a larger script. It's running on a Linux server and
manipulating some Samba stuff for the Win32 clients.
I try to avoid calling console commands because there tends to be
differences in some of the CLI utilities between distributions--that was
actually one of the first things I had considered doing, except with the
`groups` command.
That's why I said you may as well either just use the id utility from
the shell if you're not going to grab group memberships in an
idiomatically Perlish way -- the Perl code is likely to be more
portable. Of course, specifying the path to the group file, as I
originally suggested, might not be the most portable way to do that (in
retrospect).
That's interesting... But I couldn't determine another (perhaps better)
way of doing it.
I tried the getgr* and getpw* functions, but they were too
specific--that is, one has to specify which user or group they want
information about. And the user information won't tell me such things as
which groups the user belongs to... And I can't get information about a
group unless I know the group name ahead of time... And so on. This is
why I decided on the method I did. (Perhaps I wasn't doing something
correctly with those functions?)
In either case, the interesting point about your comment is that every
*nix system I've ever touched (Linux (includes Redhat, Debian, Ubuntu,
Mandrake, and Gentoo), FreeBSD, Solaris, and AIX) have all had their
group file located at /etc/group. Do you have a specific example or
reason of why someone might want to change this location?