Summary: Getting client IP address from shell

From: Hutcheson, Mike (Mike_Hutcheson@baylor.edu)
Date: Fri Jan 31 2003 - 14:50:34 EST


Fantastic! I received several very helpful responses to my question about getting the client IP address from the shell during a telnet or ssh session. The list of respondents is long so to keep things short I'll just say thanks to everyone who replied.

The simplest solution that I received from several people was to use the who -m command and pipe it through awk and sed.

#!/bin/sh
client_addr=`who -m | awk '{ printf $NF }' | sed 's/[()]//g'`

Thanks again!

Mike Hutcheson (Mike_Hutcheson@baylor.edu)
Systems Manager (254) 710-4110
Baylor University - Information Technology Services



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:06 EDT