Finding your tty

srs!matt at uhura.cc.rochester.edu srs!matt at uhura.cc.rochester.edu
Tue May 9 00:42:14 AEST 1989


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 at srs.uucp OR matt%srs.uucp at harvard.harvard.edu	-



More information about the Comp.sys.sun mailing list