Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: comp.unix.questions Subject: Re: Process ID of th shell Message-ID: <1991Jun6.142408.29248@thunder.mcrcim.mcgill.edu> Date: 6 Jun 91 14:24:08 GMT References: <11563@mirsa.inria.fr> <&~2_YC$@warwick.ac.uk> Distribution: world,local Organization: McGill Research Centre for Intelligent Machines Lines: 29 In article <&~2_YC$@warwick.ac.uk>, cstaqaf@warwick.ac.uk (Richard Broadley) writes: > Could someone tell me if there is something I can add to my .cshrc or > my .tcshrc which will be able to find out the hostname/username of > where a rsh is coming from? An rsh? You'll need to write a program. An rlogin you can make a reasonable stab at by looking at the output of programs like who. > Is it called the peername? See, you didn't need to ask; you knew the answer already! Yes, what you are looking for is termed the peer address in the socket documentation, and is obtained with the getpeername() syscall. Of course, that gets you only the machine's address. The machine's name would be obtained by applying gethostbyaddr() to the address; the remote username generally isn't available by the time your .cshrc is being read. This assumes your rshd leaves the stdin/stdout/stderr of the remote command connected directly to the pipe. To determine this, try it; if it's not so, getpeername() should fail with errno set to ENOTSOCK. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu