File: logcheck.pl

package info (click to toggle)
snap 0.08-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 440 kB
  • ctags: 473
  • sloc: perl: 7,033; makefile: 117; sh: 70
file content (38 lines) | stat: -rw-r--r-- 689 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
sub do_logcheck
{
  my ($sock, $param_str, @params) = @_;
  my $count = shift @params;
  my $logf = new FileHandle "<$logname";
  my @lines = <$logf>;
  my $i;
  my $title = "Log Output";

  $title .= "\n" . "-" x length($title) . "\n";

  $logf->close();

  print $title;

  my ($start, $end);

  if ($count < 0)
    {
      $start = $#lines + $count + 1;
      $end = $#lines + 1;
    }
  else
    {
      $start = 0;
      $end = $count;
    }

  for ($i = $start; $i < $end; $i++)
    {
      print "$lines[$i]";
    }

  print "\n";
}

$command_hash{"/logcheck"} = [\&do_logcheck];
$help_hash{"/logcheck"} = "Usage: /logcheck [n]\n\n  Prints the last <n> lines of the log file.\n\n";