Commit | Line | Data |
378cc40b |
1 | #!/usr/bin/perl -P |
2 | |
79072805 |
3 | # $RCSfile: scan_last,v $$Revision: 4.1 $$Date: 92/08/07 17:20:35 $ |
378cc40b |
4 | |
5 | # This reports who was logged on at weird hours |
6 | |
7 | ($dy, $mo, $lastdt) = split(/ +/,`date`); |
8 | |
9 | open(Last, 'exec last 2>&1 |') || die "scan_last: can't run last"; |
10 | |
11 | while (<Last>) { |
12 | #if defined(mc300) || defined(mc500) || defined(mc700) |
13 | $_ = substr($_,0,19) . substr($_,23,100); |
14 | #endif |
15 | next if /^$/; |
16 | (print),next if m|^/|; |
17 | $login = substr($_,0,8); |
18 | $tty = substr($_,10,7); |
19 | $from = substr($_,19,15); |
20 | $day = substr($_,36,3); |
21 | $mo = substr($_,40,3); |
22 | $dt = substr($_,44,2); |
23 | $hr = substr($_,47,2); |
24 | $min = substr($_,50,2); |
25 | $dash = substr($_,53,1); |
26 | $tohr = substr($_,55,2); |
27 | $tomin = substr($_,58,2); |
28 | $durhr = substr($_,63,2); |
29 | $durmin = substr($_,66,2); |
30 | |
31 | next unless $hr; |
32 | next if $login eq 'reboot '; |
33 | next if $login eq 'shutdown'; |
34 | |
35 | if ($dt != $lastdt) { |
36 | if ($lastdt < $dt) { |
37 | $seen += $dt - $lastdt; |
38 | } |
39 | else { |
40 | $seen++; |
41 | } |
42 | $lastdt = $dt; |
43 | } |
44 | |
45 | $inat = $hr + $min / 60; |
46 | if ($tohr =~ /^[a-z]/) { |
47 | $outat = 12; # something innocuous |
48 | } else { |
49 | $outat = $tohr + $tomin / 60; |
50 | } |
51 | |
52 | last if $seen + ($inat < 8) > 1; |
53 | |
54 | if ($inat < 5 || $inat > 21 || $outat < 6 || $outat > 23) { |
55 | print; |
56 | } |
57 | } |