Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to adding wtmp script into logwatch by hedkandi

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (2)
    As of 2018-08-22 03:41 GMT
    Find Nodes?
      Voting Booth?
      Asked to put a square peg in a round hole, I would:

      Results (204 votes). Check out past polls.