Process ID of th shell

der Mouse mouse at thunder.mcrcim.mcgill.edu
Fri Jun 7 00:24:08 AEST 1991


In article <&~2_YC$@warwick.ac.uk>, cstaqaf at 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 at larry.mcrcim.mcgill.edu



More information about the Comp.unix.questions mailing list