From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079044115608.tru64-unix-managers.marc@archive.invalid> From: Edward Nowlan Date: Tue, 08 Jun 1999 14:42:37 +0000 To: tru64-unix-managers Subject: Summary: How do you determine the IP address you connected with? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079044115608 I received quite a few response, rather quickly, thanks to: George Gallen "C.Ruhnke" "David J. DeWolfe" Amy Skowronek Gwen Pettigrew Sean O'Connell Paul A Sand Rob Mayfield Wayne Sweatt I choose to use the following to get the IP address and used arp ip-address to get the ethernet address. I am lucky that we are a flat network, no subnets so I can arp for my address, otherwise arp would return the router's address: who -Mm | awk '{print $6}' | sed s/\(// | sed s/\)// Other responses included: ------------------------------------------------------------------ TTY=`tty | cut -b 9-` HOSTNAME="`w | grep $TTY | paste -s - | awk '{print $3}'`" ------------------------------------------------------------------ lsof (No specifics were given and as of yet I have not tried this one) ------------------------------------------------------------------ mytty=`tty | sed -e 's/\/dev\///' ` REMOTEHOST=`who -M | grep ${mytty} | awk -F \( '{ print $2 }' | sed -e 's/)//'` If using ssh environment variable SSH_CLIENT (IP Address) and SSH_TTY (tty) ------------------------------------------------------------------ If you have tcsh then the environment variable REMOTEHOST ------------------------------------------------------------------ who -M | awk '{print $6}' | tr -d '[()]'