Link to home
Start Free TrialLog in
Avatar of BALITWPG
BALITWPGFlag for Canada

asked on

Redirect Perl output

I have three perl scripts.  The first script runs the second script and the second script will run the third script via the command system()

Each script creates output via print to the command prompt widow.

When I run the scripts and pipe the output to a file. I only get the output of the first level script.  Keeping in mind that I’m a perl newbie, what do I need to do capture all the output?

IE: C:>ScriptOne.pl > run.log
Avatar of ozo
ozo
Flag of United States of America image

do the second and third scripts print to STDERR?
Avatar of BALITWPG

ASKER

I don't think so (I didn't author these scripts). I don't see anything that looks like it's changing the standard output.  I had already tried  1>> run.log 2>>&1 with the same results.
I suppose one method might be to use backtics.

For example, you could write one script that calls all 3 scripts like so:

my $result1 = `path/to/perl/script1.pl`;
my $result2 = `path/to/perl/script2.pl`;
my $result3 = `path/to/perl/script3.pl`;

print "$result1\n$result2\n$result1\n";
Well, the calling line looks like this,  $Staus will contain a zero or a custom error number if the called script finds a problem.

$Status = system("$execution_line") ;

none of the scripts open STDOUT.

I like your idea, but I was hoping to not have to make too many changes.  I may, instead, redirect STDOUT to a file then echo that file back into my log file.
What is in $execution_line ?
I've requested that this question be closed as follows:

Accepted answer: 0 points for BALITWPG's comment #a38341959

for the following reason:

used my own work around.
Hi BALITWPG,

When accepting your own answer to a question (as you seem to be), the instructions that appear on the webpage are:
"Please state your reason for accepting your own comment as the solution. If additional information would assist others in understanding your solution, please add that information below."
I don't think "used my own work around" gives enough detail for anyone to see what you have done to fix this.

Also see that on 30-Aug ozo asked "What is in $execution_line ?", but I see no response from you.

Please follow those instructions before trying to close (or delete) this question again.

Thanks.
My previous post shows why I object to this question being closed in this way.
ASKER CERTIFIED SOLUTION
Avatar of BALITWPG
BALITWPG
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial