Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: telling rlogin from terminal login (was Re: Is this a logout ?) Message-ID: <1991Mar7.015420.27970@athena.mit.edu> Date: 7 Mar 91 01:54:20 GMT References: <1991Mar6.120728.10069@daimi.aau.dk> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 27 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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710