Subject: Re: determining originating IP address of current rsh session
To: Simon Burge <simonb@NetBSD.ORG>
From: Laine Stump <>
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 <->
>	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.

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