On Thu, 30 Jan 2003, Charles Steinkuehler wrote: > Eric R. wrote: > > Hey LugNuts, > > > > I'm trying to whip up a bash script that will report to the user at > > logon, the logon id, IP they came from, etc. > > > > > I tried netstat, and piped it to cut -c45-65 but that gave me every > > connection that netstat sees... LOL!!! not the desired effect!! > > NOTE: The $SSH_CLIENT variable is passed to the script...once the script > runs, the environment variables set by ssh disappear, and I was unable > to figure out any other means of extracting the remote IP (at least > easily in a script...I could probably crawl through proc or something, > but that seemed hard :) > `who' gets it from utmp. REMOTE_IP=`who am i|sed 's/^[^(]*(([0-9.]*):.*$/1/'` Tested on debian, probably not portable, modify as needed. Hal