Win32::Process::Create() - how to capture process output?
Posted on 2004-11-23
Here is the progression of events... (1) I have an open logfile, (2) I start a process using Win32::Process::Create, (3) I "Wait" midway through process execution time, then (4) print other stuff to the logfile.
I need to collect and print the output started at step 2 to the logfile. I don't mind using a temporary file for storage...but prefer to capture data in memory. How do I do either of these? I'm thinking simple redirection to a file in the Process::Create( ) call won't work...but have not tried it.
$proc = execute_child($profile);
proc->Wait (60 * 1000) # wait 1 minute
print_file_sizes($profile); // prints some other data to the open logfile
Win32::Process::Create ($ProcessObj2, $proc_fname, "$PROC_NAME -int $interval -samples 3",
0, NORMAL_PRIORITY_CLASS, "." );
# $PROC_NAME runs for 2 minutes - output normally goes to stdout ... its a command line process.
# I would like to capture this output somehow...?