Hi all
Firstly, I'd like to admit that my knowledge in Perl scripting is very low (you can say that I'm dumb)
I have been wanting to incorporate wtmp script that i found online into my logwatch script. As it is, when i run the script it gives me the correct output, but when i added that to logwatch the outcome is a string of errors
here's the script i am using:
my-mnag0:/etc/logwatch/scripts/services # more my-report
perl -we '@type=("Empty","Run Lvl","Boot","New Time","Old Time","Init"
+,"Login","Normal","Term","Account");$recs = ""; while (<>) {$r
ecs .= $_};foreach (split(/(.{384})/s,$recs)) {next if length($_) == 0
+;my ($type,$pid,$line,$inittab,$user,$host,$t1,$t2,$t3,$t4,$t5
) = $_ =~/(.{4})(.{4})(.{32})(.{4})(.{32})(.{256})(.{4})(.{4})(.{4})(.
+{4})(.{4})/s;if (defined $line && $line =~ /\w/) {$line =~ s/\
x00+//g;$host =~ s/\x00+//g;$user =~ s/\x00+//g;printf("%s %-8s %-12s
+%10s %-45s \n",scalar(gmtime(unpack("I4",$t3))),$type[unpack("
I4",$type)],$user,$line,$host)}}printf"\n"' < /var/log/wtmp
my-mnag0:/etc/logwatch/scripts/services #
output of the script:
my-mnag0:/etc/logwatch/scripts/services # ./my-report | more
Fri Dec 18 22:17:17 2009 Login LOGIN tty1
+
Fri Dec 18 22:17:17 2009 Login LOGIN tty2
+
Fri Dec 18 22:17:17 2009 Login LOGIN tty3
...
when the script is used with logwatch this is what i get:
--------------------- wmtp logs Begin ------------------------
String found where operator expected at /etc/logwatch/scripts/service
+s/my-report line 1, at end of line
(Do you need to predeclare we?)
Warning: Use of "log" without parentheses is ambiguous at /etc/logwat
+ch/scripts/services/my-report line 1.
syntax error at /etc/logwatch/scripts/services/my-report line 1, next
+ token ???
Search pattern not terminated at /etc/logwatch/scripts/services/my-re
+port line 1.
---------------------- wmtp logs End -------------------------
I am not sure what token is meant here because the script runs fine on its own...sorry this must seem dumb to some of you but i am fairly new to Perl. Thank you