I have a cross-platform Perl program that starts a win32 windows program on win, and a macosx appliaction on the mac.
I use system()
, which on the mac makes the stdout of the invoked program, be written in the stdout of the Perl program, which is what i want.
On Windows, it seems like there is no way to get the stdout a Windows program. So as an alternative, I m having the program write to a logfile instead, and I d like Perl to read from the logfile (as it s being written to, the invoked program could run for an hour), and redirect that back to Perl s stdout, so that the experience on Win and Mac is the same.
Does anybody know how to actually do this in Perl? I m thinking:
- fork the process
- File::Tail the logfile, writing to stdout as data comes in
- somehow figure out when the program actually finished running.
I can probably figure out #1 and #2, but don t know yet how to tackle #3.