OUTPUT DID NOT REDIRECT TO THE INTENDED FILE OPENED FOR..
Posted
by rockyurock
on Stack Overflow
See other posts from Stack Overflow
or by rockyurock
Published on 2010-04-20T10:08:08Z
Indexed on
2010/04/20
10:13 UTC
Read the original article
Hit count: 258
HELLO ALL,
I USED THE BELOW CODE FOR CAPTURING THE OUTPUT (BELOW IN lines) IN A FILE "my_output.txt" BUT FAILED TO CAPTURE.
**************output***************
inside value loop
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 108 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.16.2 port 5001 connected with 192.168.16.1 port 3189
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 5.0 sec 2.14 MBytes 3.61 Mbits/sec 0.369 ms 0/ 1528 (0%)
inside value loop3
clue1
clue2
inside value loop4
one iperf completed
***************************************
however when i enabled the local *STDOUT; in below code then i could see the above output on command prompt display (ofcourse server is sending some data).
could anybody suggest me how can i capture the o/p in a file intended?
below is the code i am using ..
my $file = 'my_output.txt';
use Win32::Process;
print"inside value loop\n";
# redirect stdout to a file
#local *STDOUT;
open STDOUT, '>', $file
or die "can't redirect STDOUT to <$file> $!";
Win32::Process::Create(my $ProcessObj,
"D:\\IOT_AUTOMATION_UTILITY\\_SATURDAY_09-04-10\\adb_cmd.bat",
"adb shell /data/app/iperf -u -s -p 5001",
0,
NORMAL_PRIORITY_CLASS,
".") || die ErrorReport();
#$alarm_time = $IPERF_RUN_TIME+10; #20sec
#$ProcessObj->Wait(40);
#print"inside value loop2\n";
#sleep $alarm_time;
sleep 40;
$ProcessObj->Kill(0);
sub ErrorReport{
print Win32::FormatMessage( Win32::GetLastError() );
}
/rocky
© Stack Overflow or respective owner