Jonathan,

'last' is designed to do almost exactly what you are trying 
to write.

if you don't use the -1 option you can see all the logins for
a user since the wtmp file was created.

but anyway, if you still need this for a different reason,
'last -a' pushes the hostname field to the last column and i think
that is doesn't get cut off anymore... I haven't tried from some 
really long hostname, but tick.ece.utexas.edu wouldn't fit in 
'last' but as shown completely in 'last -a'.

so then it is pretty easy in awk to pull that off an put it in a file

OUTPUT ===============================
neumann:~> last -1 gureckis
gureckis ttyp3        tick.ece.utexas. Sat May  1 12:51 - 12:52  (00:00)

wtmp begins Sat May  1 12:51:09 1999
neumann:~> last -1 -a gureckis
gureckis ttyp3        Sat May  1 12:51 - 12:52  (00:00)
tick.ece.utexas.edu

wtmp begins Sat May  1 12:51:09 1999
OUTPUT ==================================


hope that helps,

tod.

sorry that i sent this twice, i keep forgetting to put the list's address into
my posted messages.  seems counter intuitive for a mailing list to me but 
whatever.

Jonathan Arehart wrote:
> 
> 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.
> 
> I have found that if I'm using ssh or my shell is tcsh, I can get the
> full address from and environment variable, but I almost never use tcsh
> <grin> and don't ssh to my machine when I'm behind my ip-masq at home.
> 
> So, any ideas?
> 
> Thanks,
> Jonathan Arehart
> [EMAIL PROTECTED]
> 
> P.S.  Sorry if you get duplicate copies, one from each list...  :)
> 
> ---------------------------------------------------------------------------
> Send administrative requests to [EMAIL PROTECTED]

-- 
tod.
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to