atu has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, i have a question: I have a perl script that is calling many other scripts. My perl code is something like that:
At this point aPerlScript.pl starts with inputs 1 and 2, does a lot of stuff, and it again prints a lot of stuff on the screen. Now i want to have them on the screen but i also want to have them on a log file. if i use:lots of things here ..... system ("aPerlScript.pl 1 2"); .....
i can get them on screen and file but it is delayed a lot. aPerlScript.pl keeps running for 3-4 minutes, and lets say prints 100 rows on screen every now and then. if i use backticks to capture it, script seems to stuck during that duration, doing nothing at all, and once aPerlScript.pl completes its work, i suddenly get 3982498234 rows show on display. How can i solve that problem? TL;DR: How can i get the same output of a script that is called from another script on both screen and a log file simultaniosly?my $output = `aPerlScript.pl 1 2`; print "$output \n"; logToSomeFile "$output"; #this is a sub routine that prints to file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: script and its output on different handles
by choroba (Cardinal) on Nov 28, 2013 at 10:39 UTC | |
|
Re: script and its output on different handles
by hdb (Monsignor) on Nov 28, 2013 at 10:39 UTC | |
|
Re: script and its output on different handles
by drmrgd (Beadle) on Nov 28, 2013 at 13:03 UTC |