How To Get The Outout of Win32::Process command in perl
- by rockyurock
hello all,
i am using "use Win32::Process" for my application run as below, it runs fine but i did not get any way to get the output to a .txt file.
i used NORMAL_PRIORITY_CLASS rather than CREATE_NEW_CONSOLE to get the output on the same terminal itself but i don't know how to redirect it to a txt file.
/rocky
!/usr/bin/perl
use strict;
use warnings;
use Win32::Process;
Win32::Process::Create(my $ProcessObj,
"iperf.exe",
"iperf.exe -u -s -p 5001",
0,
NORMAL_PRIORITY_CLASS,
".") || die ErrorReport();
my @command_output;
push @command_output,$ProcessObj;
open FILE, "zz.txt" or die $!;
print FILE @command_output;
close FILE;
sleep 10;
$ProcessObj-Kill(0);
sub ErrorReport{
print Win32::FormatMessage( Win32::GetLastError() );
}