Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!rice!sun-spots-request From: srs!matt@uhura.cc.rochester.edu Newsgroups: comp.sys.sun Subject: Re: Finding your tty Keywords: Software Message-ID: <8904261435.AA28599@flash.srs.com> Date: 8 May 89 14:42:14 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 49 Approved: Sun-Spots@rice.edu Original-Date: Wed, 26 Apr 89 10:35:23 EDT X-Sun-Spots-Digest: Volume 7, Issue 275, message 2 of 25 Dave Driver actually came up with a pretty good solution to the problem of finding what terminal you originally logged in on. Solving the "rlogin" problem can be tricky, but since Dave's solution would return the pty of the original rlogin, it seems to be a good compromise (i.e. it would only return the "wrong" info if you rlogged into the same machine). The reason his solution works is that the .login file only gets executed when the shell is a "login" shell. An environment variable would then be propagated along containing the tty name of the login shell. Pretty much what was asked for. It would certainly work "right" for suntools, just a little questionable for rlogins... THE PROVERBIAL EXAMPLE (a slightly doctored script): Script started on Wed Apr 26 10:24:37 1989 flash% cat .login setenv LOGTTY `tty` flash% cat .cshrc setenv MYTTY `tty` flash% rlogin dash Last login: Fri Mar 31 10:23:36 from flash Sun UNIX 4.2 Release 3.2 (DASH) #29: Tue Feb 21 14:09:11 EST 1989 You have mail. dash% tty /dev/ttyp0 dash% echo $LOGTTY /dev/ttyp0 dash% echo $MYTTY /dev/ttyp0 dash% screen /* screen starts up three sub-windows */ dash% echo $MYTTY /dev/ttyp7 dash% echo $LOGTTY /dev/ttyp0 dash% ^D /* log out of first */ dash% echo $MYTTY /dev/ttyp5 dash% echo $LOGTTY /dev/ttyp0 dash% ^D /* log out of second */ dash% ^D /* exit screen program */ dash% logout /* logout of machine "dash" */ Connection closed. flash% ^D script done on Wed Apr 26 10:26:39 1989 ----- - uucp: {rutgers,ames}!rochester!srs!matt Matt Goheen - - internet: matt@srs.uucp OR matt%srs.uucp@harvard.harvard.edu -