"Thus spake Jonathan Arehart"
> Hello all,
> 
> I'm working on a python script at the moment that will write the date and
> location from which I log in each time I do so.  However, I've not found
> an easy way to get the IP address or hostname from which I'm connecting
> that is consistent across Un*ces (Linux and FreeBSD in my case).  I've
> thought about parsing the information out of finger output which is
> possible but kinda annoying.  The other option I've found is using the
> output of last -1 <username>, but if the hostname is very long, I can't
> get all of it and would like to.  

Better than just using netstat -a or netstat -an, you can add the -e option,
if it's supported by netstat on all your unices, and grep for your username
as well as for the telnet or ssh name or port.  This will pin down your
connection process with certainty unless, possibly, you're connected
multiple times, in which case the most recent connection may still be
uppermost in the socket table.  You'll need to check it out.

-- 
Lindsay Haisley       | "Everything works    |     PGP public key
FMP Computer Services |       if you let it" |      available at
[EMAIL PROTECTED]        |    (The Roadie)      | <http://www.fmp.com/pubkeys>
http://www.fmp.com    |                      |
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to