whoami?

Eric Schenk schenk at fsd.cpsc.ucalgary.ca
Fri Jan 4 17:17:00 AEST 1991


I wrote:
>>In article <6624 at crash.cts.com> jca at pnet01.cts.com (John C. Archambeau) writes:
>>
>>I want the equivalent of whoami on BSD/SunOS for SCO Xenix that will work on
>>both the Bourne and C Shells.
>
>The GNU bin tools package has a whoami command that seems to be BSD lookalike.
>I've compiled it on my machine without problems using gcc, but it's
>probably simple enough to use cc as well.

Unfortunatly this is not true.  I noticed in passing that I had whoami
in /usr/local/bin on my system, and for unknown reason I assumed that
it was part of the GNU bin tools distribution.  In fact my copy is
from the BSD free sources, and was distributed as part of the MGR
distribution for xenix.  Since the source is so small I've include
the shar file below.

Enjoy

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  whoami.c
# Wrapped by schenk at cpsc.UCalgary.CA on Thu Jan  3 23:11:35 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'whoami.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'whoami.c'\"
else
echo shar: Extracting \"'whoami.c'\" \(1326 characters\)
sed "s/^X//" >'whoami.c' <<'END_OF_FILE'
X/*
X * Copyright (c) 1988 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1988 Regents of the University of California.\n\
X All rights reserved.\n";
X#endif /* not lint */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)whoami.c	5.3 (Berkeley) 6/29/88";
X#endif /* not lint */
X
X#include <sys/types.h>
X#include <pwd.h>
X
Xmain()
X{
X	struct passwd *p, *getpwuid();
X	int uid;
X
X	uid = geteuid();
X	if (!(p = getpwuid(uid))) {
X		printf("whoami: no login associated with uid %u.\n", uid);
X		exit(1);
X	}
X	printf("%s\n", p->pw_name);
X	exit(0);
X}
END_OF_FILE
if test 1326 -ne `wc -c <'whoami.c'`; then
    echo shar: \"'whoami.c'\" unpacked with wrong size!
fi
# end of 'whoami.c'
fi
echo shar: End of shell archive.
exit 0
-------------------------------------------------------------------------------
Eric Schenk               Department of Computer Science, University of Calgary
schenk at cpsc.ucalgary.ca   Just another graduate slave.
-------------------------------------------------------------------------------



More information about the Comp.unix.xenix.sco mailing list