SUMMARY: number days since last login

From: Steve Bagdon <>
Date: Thu Jul 25 2002 - 11:20:28 EDT
And the winner is - Neil Hunt:

"Perhaps you can look at Sys::Lastlog"

Just about everyone says - how hard can it be? Until they try to write it. Last/finger provides some amount of randomness on reporting of date formats, and I wasn't in the mood to write C code to use lastlog.h. So, here's a slice of Perl code to do this:

#!/usr/bin/perl -w

use Sys::Lastlog;
use vars qw( $login $port $host $when);

$ll = Sys::Lastlog->new();
$llent = $ll->getlluid(0);
$days = int((( time - $llent->ll_time() ) / 60 / 60 / 24));

print "days = $days\n";


Thanks to all, and I'll be more clear on my next request... :)


Steve B.
sunmanagers mailing list
Received on Thu Jul 25 12:06:04 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:50 EST