• Important: We recently upgraded our forum software - please let us know if you run into any issues.

Getting IP address on logout

AntiRix

New Member
Hi,

I've managed to write a script which logs whether or not a connection is via SSH or direct, along with the IP address of the connecting party, but I can't get it to work the same on logout.

I created a script at ~/.logout which is called via
Code:
trap '$HOME/.logout' 0
in ~/.profile. The script is called, but it seems $SSH_CONNECTION is undefined at that point, so it's reporting SSH connections as not via SSH.

~/.logout:
Code:
#!/bin/sh

if [[ -n $SSH_CONNECTION ]] ; then
        (/var/www/html/logging/logout-report ssh $(echo $SSH_CONNECTION | awk '{print $1}') &)
else
        (/var/www/html/logging/logout-report direct &)
fi

exit 0
I can only imagine that the SSH connection is closed by the time this script is run. Is there any way around this?
 


wizardfromoz

Super Moderator
Staff member
Gold Supporter
Most of our scripting enquiries are answered in Command Line, so I am moving this there for better attention.

Wizard
 

Members online



Top