On 2005 Feb 28 , at 18.00, Peter W. Draper wrote:
> On Fri, 25 Feb 2005, Tim Jenness wrote:
>
>> I think 'whoami' is a UCB extension. On my solaris 8 box it's in
>> /usr/ucb/whoami.
>>
>> are we meant to use something portable like
>>
>> who am i | awk '{ print $1 } '
>
> Possibly, but peering at the UNIX standard it might be better to just
> use
> the "logname" command. Anyone else got any insight on this? I notice
> we do
> use "whoami" in other scripts (I'm the main culprit) in CCDPACK,
> DATACUBE
The standard also mentions 'who am i' as producing the username in the
first field.
logname 2>/dev/null || who am i | awk '{print $1}'
would produce the same results, without failing if the standard
`logname' isn't present, or
{ logname || whoami || who am i | awk '{print $1}'; }2>/dev/null
if you want to get fancy and comprehensive.
The autoconf portability notes don't mention this.
Norman
--
----------------------------------------------------------------------
Norman Gray : Physics & Astronomy, Glasgow University, UK
http://www.astro.gla.ac.uk/users/norman/ : www.starlink.ac.uk
|