xsay: add support for sselp and xclip; output error message
[grml-scripts.git] / usr_bin / logview
1 #!/usr/bin/perl
2 # Filename:      logview
3 # Purpose:       Log viewer program. Pass it parameters of the logs to view, or it will automatically view some.
4 # Authors:       Joey Hess <joey@kitenet.net>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       Unknown (origin: see http://svn.kitenet.net/trunk/bin/logview)
7 # Latest change: Fri Sep 16 18:19:05 CEST 2005 [mika]
8 ################################################################################
9
10 $|=1;
11
12 $logdir='/var/log';
13 @logfiles=@ARGV;
14
15 # If I am root, look at all logs, otherwise only those that are
16 # world-readable.
17 my $perm='';
18 $perm='-perm +6' if $? != 0;
19 if (! @logfiles) {
20         @logfiles=split /\n/, `find $logdir -type f -regex '.*.log' ! -name faillog ! -name lastlog $perm`;
21         push @logfiles, "$logdir/mail.err", "$logdir/mail.warn";
22 }
23
24 if (-e $ENV{HOME}."/.xsession-errors") {
25         push @logfiles, $ENV{HOME}."/.xsession-errors";
26 }
27
28 # Tail without wasting the last line of the screen.
29 open(TAIL, "tail -q --follow=name --retry -n 2 @logfiles|");
30 while (<TAIL>) {
31         print "\n";
32         chomp;
33         print $_;
34 }
35
36 ## END OF FILE #################################################################