2 # Functions for hpux format last output
5 # Returns 0 for old-style passwords (/etc/passwd only), 1 for FreeBSD-style
6 # (/etc/master.passwd) and 2 for SysV (/etc/passwd & /etc/shadow)
13 # Returns 0 for normal group file (/etc/group only) and 2 for shadowed
14 # (/etc/group and /etc/gshadow)
20 # open_last_command(handle, user)
23 local ($fh, $user) = @_;
24 open($fh, "last -R $user |");
27 # read_last_line(handle)
28 # Parses a line of output from last into an array of
29 # user, tty, host, login, logout, period
35 if (!$line) { return (); }
36 if ($line =~ /system boot/) { next; }
37 if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+\-\s+(\d+:\d+)\s+\((\d+:\d+)\)/) {
38 return ($1, $2, $3, $4, $5, $6);
40 elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+still/) {
41 return ($1, $2, $3, $4);