• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 528
  • Last Modified:

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
0
BALITWPG
Asked:
BALITWPG
  • 4
  • 2
  • 2
  • +1
1 Solution
 
ozoCommented:
do the second and third scripts print to STDERR?
0
 
BALITWPGAuthor Commented:
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.
0
 
whosbetterthanmeCommented:
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";
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
BALITWPGAuthor Commented:
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.
0
 
ozoCommented:
What is in $execution_line ?
0
 
BALITWPGAuthor Commented:
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.
0
 
tel2Commented:
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.
0
 
tel2Commented:
My previous post shows why I object to this question being closed in this way.
0
 
BALITWPGAuthor Commented:
I've requested that this question be closed as follows:

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

for the following reason:

I redirected STDOUT to a seperate file for each script and will live with that as a work around.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now