Knowing what OS would help.
So would answers to such questions as
- "Does 'running continuously for some time' mean that it runs to completion soon enough that you won't have to take your eyes off your monitor before that happens (or, alternately, that you can leave your cube at quitting time and read the results in the morning)?
- "What (plain text? formatted somehow? a database update?) does your executable "print to a file?"
- "Is that file a temp that's unlinked before your script starts?"
Please read On asking for help and How do I post a question effectively?.
Nonetheless, here's a WAG -- barebones, unelaborated pseudocode for near-"real time" reading -- avoiding many OS specific ways to check what the executable is up to, the possibility (probability?) that the output is formatted as something other than simple text, whether the executable locks the file it's writing in increments, etc.
#!shebang
use strict;
use warnings;
# do ...; # (whatever sets up the call)
call executable # (using system, exec, backticks or ....);
# First time check for file written by executable
if (exists $thefile) { # the file_in_line_13) {
readit();
} else {
sleep (some amount of time);
goto (in some form or another) 18;
}
sub readit {
open '<', EXEOUT, $thefile ;
$latest = <EXEOUT>;
close EXEOUT;
print "$latest \n"; # (to user);
recheck();
}
sub recheck {
my $timesIdential = 1;
sleep (time);
open '<', EXEOUT, $thefile ;
$newlatest = <EXEOUT>;
if ( $newlatest ne $latest ) {
clearscreen (OS dependant);
readit();
} else {
$timesIdentical++;
if ($timesIdentical = n) {
# for some "n" sufficient to convince you
# that the executable is done
clearscreen;
print "Done\n\n" . $newlatest . "\n";
exit();
}
}
}
As always, the devil is in the details.
Update, given the detail (parallel processing) in the reply below.
Change line 22 to call a sub wherein (given this structure) you'll throw out any prior processing (wasteful and probably NWYW (® "not what you want") and to do your processing (again).
But we still have no idea of how intensive that processing is, nor how time-critical. Each of those will probably make the replacement suggested in the previous paragraph, in the infamous words of a one-time White House spokesman, "inoperative." |