Nombre: lastlog.pl
Autor: ph
Visto en: Tech Notes
Leer más...
Autor: ph
Visto en: Tech Notes
#!/usr/local/bin/perl # month names for common usage @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); setpwent; while (($name, $junk, $uid) = getpwent) { $names{$uid} = $name; } endpwent; open(LASTL,'/var/adm/lastlog'); for ($uid = 0; read(LASTL, $record, 28); $uid++) { ($time, $line, $host) = unpack('l A8 A16', $record); next unless $time; $host = "($host)" if $host; ($sec, $min, $hour, $mday, $mon, $year) = localtime($time); printf "%-9s%-8s%s %2d %4d %s\n", $names{$uid}, $line, $months[$mon], $mday, 1900+$year, $host; }