Hello guys i need to capture the output of an external command, herefore I use backquotes.
However when the command reaches a newline the output is ommitted. Where $_ = AD
@lines = `"C:/Program Files/Veritas/NetBackup/bin/admincmd/bppllist" $_ -U"`
Test: test1 Test: test2 Test: test3 Test: test4
The actual output:
@lines
Test: test1 Test: test2
Thank you for your time.
print HTML "<h2 id='pol'>Policy Configuration\n</h2>" ;
@bpllist =`"$admincmd/bppllist.exe"` or die print "$admincmd/bppllist.exe not found or could not be executed";
foreach (@bpllist)
{
print HTML "<div><table class='table'>\n";
@lines = `"$admincmd/bppllist" $_ -U` or die print "$admincmd/bpplinfo $_ -U not found or could not be executed";
print HTML "\t<tr>\n\t<td><b>Policy name: <b></td><td>$_</td>\n\t</tr>\n" ;
foreach (@lines) {
chop;
($var, $value) = split(/:/,$_,2);
$var = "" if !defined($var);
$value = "" if !defined($value);
print HTML "\t<tr>\n\t<td>$var</td><td>$value</td>\n\t</tr>\n" ;
}
print HTML "</table></div>";
}
The output of @bpllist:
AD
Sharepoint
Echchange
Vmware
Here’s how to capture the STDOUT & STDERR of a spawned process using backticks:
How it works has no dependence whatsoever on newlines in the output of
command.If you also need to send text to
command‘s STDIN, then use IPC::Open3.Cleaned your code up a bit. It works for me.
Update 2
You appear to be doing this on windows?
I don’t think the
2>&1trick will work there.