Xref: utzoo alt.sources:1547 comp.lang.perl:511 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!brutus.cs.uiuc.edu!jarthur!elroy.jpl.nasa.gov!jato!lwall From: lwall@jato.Jpl.Nasa.Gov (Larry Wall) Newsgroups: alt.sources,comp.lang.perl Subject: Re: Version of id(1). Message-ID: <2964@jato.Jpl.Nasa.Gov> Date: 2 Mar 90 08:23:50 GMT References: <426@clover.warwick.ac.uk> Reply-To: lwall@jato.Jpl.Nasa.Gov (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 35 In article <426@clover.warwick.ac.uk> alfie@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