0

I am new to perl. I am executing a set of batch files in a perl script. I need to send the output(print statements and errors) of the batch file to a log file. The same log file that will have the output of my perl script. I have found many ways to put the output of the perl script to a log file but the output of the batch process that is called from the perl script is still not going to the logs.

My script looks something like this:

#!/usr/bin/perl
use strict;
use warnings;
use File::Path;
use File::Copy;
.
.
Print "abc";
.
my @args= ('C:\SBS\Install\UpgradeSBSDB_Oracle.bat');
open (FHU,"|@args") or die "Fail to open Upgrade.batch file: $!";
print FHU "\n";
.
.
Print " xyz";
.
.

The output in log looks like abc xyz

I also need the output of the batch file called in the logs

1 Answer 1

0

Try to start your system call with backticks:

my $output =  `'C:\SBS\Install\UpgradeSBSDB_Oracle.bat`;
print FHU $output."\n";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.