Subject: Re: determining originating IP address of current rsh session
To: Simon Burge <simonb@NetBSD.ORG>
From: Laine Stump <lainestump@rcn.com>
List: netbsd-users
Date: 03/18/2000 21:34:07
At 12:06 PM 3/19/00 +1100, Simon Burge wrote:
> 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
172.73.42.244:514 <-> 172.73.42.42:1011
> simonb tcsh 5209 17* internet stream tcp c05a16e0
172.73.42.244:514 <-> 172.73.42.42:1011
> simonb tcsh 5209 18* unix stream c060f2c0 <-> c060f3c0
> simonb tcsh 5209 19* internet stream tcp c05a16e0
172.73.42.244:514 <-> 172.73.42.42:1011
>
>In this case I'm rsh'ing from 172.73.42.42 to 172.73.42.244. You
>could then use some awk to grab the relevent fields.
That definitely contains the info I need. Interestingly, when I do that
command into an account that uses bash as its shell, the "CMD" field says
"fstat" instead of "bash".
>Something like Andrew's getpeer.c is probably easier to use :-)
Yes, it's fairly straightforward, and it works well. (Thanks, Andrew!) I
would prefer something that could be done completely with sh and awk (and
was portable to other OSes) so that I could just install a single shell
script that would work on anything, but this is definitely better than
nothing.