in reply to System() question

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.

Replies are listed 'Best First'.
Re^2: System() question
by ibeneedinghelp (Initiate) on Jun 13, 2006 at 17:05 UTC
    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;
    }