Subject: Re: determining originating IP address of current rsh session
To: Laine Stump <>
From: Simon Burge <>
List: netbsd-users
Date: 03/19/2000 12:06:09
Laine Stump wrote:

> There must be a simple way to do this, and I'm just suffering from brain
> rot...
> I need for a shell script executed by rsh from another machine to tell
> me the IP address of the originating machine. For example, if I'm on
> and I give the command "rsh whatsmyip", it should
> display "". (In practice I'll use rexec so that the person
> attempting to run the command (from some random IP address) is
> authenticated, but the principle should be the same.

	balrog:~ 2742> rsh wincen fstat -p '$$'
	USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
	simonb   tcsh        5209   wd /home      4096 drwxr-xr-x    3584 r 
	simonb   tcsh        5209   16* internet stream tcp c05a16e0 <->
	simonb   tcsh        5209   17* internet stream tcp c05a16e0 <->
	simonb   tcsh        5209   18* unix stream c060f2c0 <-> c060f3c0
	simonb   tcsh        5209   19* internet stream tcp c05a16e0 <->

In this case I'm rsh'ing from to  You
could then use some awk to grab the relevent fields.

Something like Andrew's getpeer.c is probably easier to use :-)