Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Report generation using perl script

by vel4ever (Initiate)
on Jul 11, 2013 at 15:25 UTC ( [id://1043759]=perlquestion: print w/replies, xml ) Need Help??

vel4ever has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working code tail -f /$LOG_DIR/app.log | perl $SCRIPT_DIR/run_report.pl /code But if i use cat command it works, code cat /$LOG_DIR/app.log | perl $SCRIPT_DIR/run_report.pl /code Please advice to use tail or any other commands to create the report dynamically instead of cat. Edit/Delete Message

Replies are listed 'Best First'.
Re: Report generation using perl script
by Utilitarian (Vicar) on Jul 11, 2013 at 15:40 UTC
    tail -f never returns, I'm going to make a wild guess that you iterate over the log file, however if the stream (from tail -f) doesn't return, then the stats you're gathering are never finished so your "And finally print the report" block is never executed, just guessing mind.

    You could repeatedly scan the file, or re-run the 2and finally" block after each line, but without the code it's hard to know what the issue is.

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: Report generation using perl script
by toolic (Bishop) on Jul 11, 2013 at 15:33 UTC
    • Writeup Formatting Tips: don't use square brackets for code blocks
    • You need to post the relevant code from run_report.pl
Re: Report generation using perl script
by mtmcc (Hermit) on Jul 12, 2013 at 10:10 UTC
    tail -f should send it's output to your perl script.

    For example:

    tail -f file.txt | script.pl

    using the script.pl:

    #!/usr/bin/perl use strict; while (<STDIN>) { print STDERR "Received from tail -f:\t$_"; }

    does print to STDERR while tail -f is running. And if 'file.txt' is updated while tail -f is still running, the output is updated.

    Do you really need to follow the log file continuously, or do you just want to create reports intermittently or on demand?

    Maybe there's an issue in your perl script?

    -Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1043759]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found