[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SAGE] Identifying client IP



We have an application that runs on Linux that needs to set the DISPLAY
variable to the client's IP address (DNS is messed up due to replication
delays etc). The vendor is using a script that identifies the client's
TTY and uses that information to get the client's IP address by combing
through the /var/log/wtmp file. This file is not very 'clean'. Is there
a reliable to way (from within a shell script) to get the client's IP
address?

Thanks
Dilan 


Ps. Here is the current script fragment. It is failing because of
duplicate tty entries inside the wtmp file :|

TTY=`tty|sed -e 's/\/dev\///'`
HOST=`utmpdump /var/run/utmp 2>/dev/null | grep "$TTY" |\
          sed -e 's/\] \[/|/g' -e 's/ //g' | awk -F\| '$4 ~ /./ {print
$7}'`