Path: utzoo!attcan!uunet!fsc2086!jim From: jim@fsc2086.FSC.COM (Jim O'Connor) Newsgroups: comp.unix.xenix Subject: Re: Finding the user name via the shell Summary: support for $LOGNAME is easy to add if you want it Keywords: shell variables Message-ID: <354@fsc2086.FSC.COM> Date: 9 Dec 88 17:13:48 GMT References: <6323@polyslo.CalPoly.EDU> <249@tfli.UUCP> <484@fallst.UUCP> Organization: Filtration Sciences Corp., Chattanooga, TN Lines: 46 In article <484@fallst.UUCP>, tkevans@fallst.UUCP (Tim Evans) writes: > In article <249@tfli.UUCP>, mikej@tfli.UUCP (Michael R. Johnston) writes: > > > > The correct answer is to use the variable $LOGNAME. > > Although the $LOGNAME variable is supported generally on System V *NIX, SCO > Xenix 2.2 does _not_ support it. Rather, as I and others have noted here > previously, the Xenix _command_ 'logname' (note lowercase) returns the > user's login name. Actually, it's just that Xenix 2.2 doesn't set it automatically at login time. If you are used to having the $LOGNAME variable present (such as I was when switching from Altos Xenix to SCO Xenix) and your "login" program won't set it for you, just add: LOGNAME=`logname` # or any program that will return the user's log name export LOGNAME to your /etc/profile file or your user's individual profiles and then $LOGNAME will be available. This is also handy for other "constants" that usually require running some program to get the value of. For example, LOCALSYS=`uuname -l` PORT=`tty` ... export LOCALSYS PORT . . . Then, if you write many shell scripts that require these values, you can look them up in the environment and save a little fork() and exec() time (same argument as for shell built-in commands). But, if you don't use these values much, you'd probably be better off just running hte program in the scripts themselves, and save the extra time it would take to process everyone's login sequence. It's the old "6 of one, half-dozen of the other" type thing, and you just have to decide for yourself which one is better. If you are writing scripts to port to other machines, however, you should probably use the program in the script, since you wouldn't want to assume other systems will use the pre-set variables. --jim ------------- James B. O'Connor jim@FSC.COM Filtration Sciences Corp. +1 615 821 4022 x651 105 W. 45th St. - Chattanooga, TN 37409