Version of id(1).

Larry Wall lwall at jato.Jpl.Nasa.Gov
Fri Mar 2 19:23:50 AEST 1990


In article <426 at clover.warwick.ac.uk> alfie at cs.warwick.ac.uk (Nick Holloway) writes:
: I saw a request somewhere for a program like the SysV id(1). I got used
: to it under SunOS, and so I wrote this one to use on our BSD machines.
: As far as I can tell, they act identically - though I can't check this,
: since I do not have access to source. The only area they may differ is
: if the user or group name can not be determined.

For those of you who can't remember where you keep .c files, here's the
one I use.  It differs slightly in that it sorts the groups.

#!/usr/bin/perl
print "uid=$<";
print "($name)" if ($name) = getpwuid($<);
print " gid=", $( + 0;
print "($name)" if ($name) = getgrgid($();
if ($> != $<) {
    print " euid=$>";
    print "($name)" if ($name) = getpwuid($>);
}
if ($) != $() {
    print " egid=", $) + 0;
    print "($name)" if ($name) = getgrgid($));
}
@groups = split(' ',$();
shift(@groups);
for (@groups) {
    $_ .= "($name)" if ($name) = getgrgid($_);
}
print " groups=", join(',',sort bynum @groups) if @groups;
print "\n";
sub bynum { $a - $b; }

No doubt Randal could write it shorter...

Larry



More information about the Alt.sources mailing list