#!/bin/perl open(LASTLOG, '/var/adm/lastlog') or die "$0: $!"; $uid = getpwnam('mm64') or die "$0: $!"; $length = 28; #sizeof struct lastlog in /usr/include/lastlog.h seek(LASTLOG, $length * $uid, 0) or die "$0: $!"; if (read(LASTLOG, $buffer, $length) != 28) { die "$0: $!"; } $seconds = unpack("i", $buffer); $string = localtime($seconds); print $string, "\n"; close(LASTLOG) or die "$0: $!"; exit 0;