Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!isavax.isa.com!cjbsys!cliffb From: cliffb@cjbsys.bdb.com (cliff bedore) Newsgroups: comp.unix.xenix.sco Subject: Re: LOGNAME, USER variables under Xenix Message-ID: <1991May1.002632.15800@cjbsys.bdb.com> Date: 1 May 91 00:26:32 GMT References: <4731@peora.sdc.ccur.com> <1991Apr26.231504.9581@bilver.uucp> Organization: BDB Systems Lines: 92 In article <1991Apr26.231504.9581@bilver.uucp> bill@bilver.uucp (Bill Vermillion) writes: >In article <4731@peora.sdc.ccur.com> tran@peora.sdc.ccur.com (Nhan Tran) writes: > >> When I log in Xenix, running /bin/sh, the environment variable LOGNAME >>and USER are not set. And Xenix doesn't have whoami command. > >Xenix does have a whoami command, except is typed who am i three >words. > > >-- >Bill Vermillion - UUCP: uunet!tarpit!bilver!bill > : bill@bilver.UUCP The problem is that when you su, who am i gives your login name not root. There is a whoami program available. I've included it as a shar file Cliff : #! /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. -------------------------------------------------------------------------------