On Mon, 28 Feb 2005, Norman Gray wrote:
> 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.
Thanks Norman, I've used the first simple version since who of logname
should be enough. Just changed HTX the others will have to wait for
another day.
Peter.
|