Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!mit-eddie!uw-beaver!ubc-cs!alberta!cpsc.ucalgary.ca!news From: schenk@fsd.cpsc.ucalgary.ca (Eric Schenk) Newsgroups: comp.unix.xenix.sco Subject: Re: whoami? Summary: whoami is not part of the GNU bin tools, but here it is. Message-ID: <1991Jan4.061700.19141@cpsc.ucalgary.ca> Date: 4 Jan 91 06:17:00 GMT References: <6685@crash.cts.com> <1991Jan4.005304.11843@cpsc.ucalgary.ca> Organization: U. of Calgary Computer Science Lines: 89 Nntp-Posting-Host: fsd I wrote: >>In article <6624@crash.cts.com> jca@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 '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 X#include 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@cpsc.ucalgary.ca Just another graduate slave. -------------------------------------------------------------------------------