hedkandi has asked for the wisdom of the Perl Monks concerning the following question:
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:
output of the script: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 #
when the script is used with logwatch this is what i get: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 ...
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--------------------- 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 -------------------------
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: adding wtmp script into logwatch
by NetWallah (Canon) on Nov 30, 2011 at 04:03 UTC | |
by hedkandi (Initiate) on Nov 30, 2011 at 09:09 UTC | |
by NetWallah (Canon) on Dec 01, 2011 at 00:45 UTC | |
Re: adding wtmp script into logwatch
by sundialsvc4 (Abbot) on Nov 30, 2011 at 04:20 UTC | |
by hedkandi (Initiate) on Nov 30, 2011 at 09:14 UTC | |
by Sinistral (Monsignor) on Nov 30, 2011 at 18:10 UTC | |
by hedkandi (Initiate) on Dec 01, 2011 at 02:01 UTC | |
by hedkandi (Initiate) on Dec 01, 2011 at 02:10 UTC | |
by hedkandi (Initiate) on Dec 01, 2011 at 02:27 UTC | |
by hedkandi (Initiate) on Dec 01, 2011 at 02:55 UTC |
Back to
Seekers of Perl Wisdom