Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

That's because you can't copy and paste the entire thing as a .pl file and expect Perl to understand. Here's what you need to have as the contents of the .pl file:

#!/bin/perl @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, $t +4, $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"

The next step after saving your .pl file is to make it executable using the chmod command. A chmod u+x,g+x,o+x wtmp.pl will do it. Then you can run the script like so:

./wtmp.pl

The above assumes that wtmp.pl is in your current directory.


In reply to Re^3: adding wtmp script into logwatch by Sinistral
in thread adding wtmp script into logwatch by hedkandi

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found