If the GUI does write the output before the user quits, but your script doesn't read it because it's waiting for the GUI to finish, you can probably fix this with system("prog ... &"), which will run the program in the background without waiting for it to finish (this is a quick way of doing fork, as McDarren suggests).
If it doesn't write the output until it exits, you can kill it with kill when you think it's probably done, or else close its window with the xkill program.
You may also want to look closely at whether the program has a "non-interactive" mode, or what it does if $ENV{DISPLAY} is unset.
| [reply] [d/l] [select] |
Cool, I appreciate everybodies help. I tried running the fork method first and got it working and then tried system("....&"). Both worked wonderfully. I had to add the following code to look for when the output log was written and look for a tag that shows when it is done being written too. I'm worried thought that this may not be the most efficient way of accomplishing this. Will the continual checking take up too much processing time? Thanks
while (open (OUTPUT, "$path/output.txt") == 0) {
if ($cnt == 0) {
print "Waiting for Output.log from Program\n\n";
}
$cnt++;
}
my($lastline) = 0;
until ($lastline =~ m/END_OF_FILE/) {
open (OUTPUT, "$path/output.txt") or die "Can't open output log: $!\n";
while (<OUTPUT>) {
$lastline = $_;
}
close OUTPUT;
unless ("$lastline" =~ "$prevline") {
print $lastline;
}
$prevline = $lastline;
}
| [reply] |
| [reply] |
Hi ibeneedinghelp,
I think that your question is unfortunately a little vague. Rather than risk guessing exactly what you're trying to do, I'd like to recommend that you provide some example code, which will give me (and other monks) the opportunity to try running it, and see what it is that's not happening the way you'd expect or hope.
A good tip: if you have a LOT of code, try whittling it down so that it exhibits the behavior you're having questions on. This will potentially yield an extra benefit, in that you may discover the problem yourself.
But even if it doesn't, the shorter a script (or scripts) that you can provide, the more eager many of the seasoned veterans here will be to "dive in" and point you towards the path of enlightenment.
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
| [reply] |
Thanks for the tip liverpole... I didn't realize how vague my question actually was until I had posted it. Looks like fork and system(... &) solved the problem. I still had to figure out how to check to see if the output was done, included the code for how I did that below. Thanks again.
| [reply] |
Sounds to me like you need to use fork | [reply] |