#!/usr/bin/perl -w use strict; my $wtmp_fmt = 'x44 A32 x264 l x40'; open(WTMP, './wtmp') || die "Unable to open wtmp file: $!\n"; my $rec; my $rec_size = length pack ($wtmp_fmt, ()); my $reccount = 0; while (read(WTMP, $rec, $rec_size)) { $reccount++; print length $rec, ' - '; if (length $rec < $rec_size) { print "\n"; last; } my @data = unpack($wtmp_fmt, $rec); my $name = $data[0] || ''; my $logtime = localtime($data[1]) || ''; print "$name\tat $logtime\n"; } close WTMP; print "$reccount records read\n"; #### 384 - root at Wed May 3 11:42:48 2006 384 - at Wed May 3 11:42:49 2006 384 - admin_esper at Mon May 8 13:01:38 2006 384 - at Mon May 8 13:01:40 2006 384 - root at Mon May 8 14:45:49 2006 ... 384 - root at Mon May 22 10:15:37 2006 108 records read #### 384 - root at Wed May 3 11:42:48 2006 384 - at Fri Jan 2 00:59:44 1970 384 - sper^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@smspap1 at Tue Oct 26 10:21:36 1999 384 - at Wed Dec 31 18:00:00 1969 384 - ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@smspap100l.xxxxxx at Wed Dec 31 18:00:00 1969 ... 384 - }í at Wed Dec 31 18:00:00 1969 79 - 108 records read #### 384 - root at Thu Aug 30 22:55:32 1906 384 - at Wed Mar 13 03:15:48 1907 384 - admin_esper at Sat Apr 18 15:48:52 1903 384 - at Wed May 11 00:29:24 1904 384 - root at Fri Mar 25 04:51:48 1960 ... 384 - root at Wed Sep 8 00:48:36 1915 108 records read