telling rlogin from terminal login (was Re: Is this a logout ?)

Jonathan I. Kamens jik at athena.mit.edu
Thu Mar 7 11:54:20 AEST 1991


  This question has come up before, and the answer is that there is no
portable way of finding out if you're current session is a remote login or a
tty login.  In order to be able to help you really effectively, we need to
know what kind of hardware you're using and what operating system it's running.

  I can give you an example of how I would do it, though.  I almost always log
in under X when I log in on a workstation, so running "who" on a machine into
which I'm logged in on the console will print out a line for me ending in
"(:0.0)".  Therefore, I can do something like this (in csh):

	set tty = `tty`
	set remote = `who | grep "$tty:t" | grep -c -v "(:0.0)"`

I could use one awk process on the last line instead of two greps, but you get
the idea.  I could also use one perl process to do the whole thing, including
reading from the utmp file :-).

  You could do something like this, if you know what "who" will print for you
whe you're logged in on a terminal and what it will print when you're logged
in remotely.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list