jim99 has asked for the wisdom of the Perl Monks concerning the following question:
1. $matlab_cmd_str = "$path_to_matlab -nodesktop -r my_script"; 2. open(RUN_MATLAB, "$matlab_cmd_str |") or die("Can't run $matlab_cmd_str: $!\n"); 3. while(<RUN_MATLAB>) { 4. print FH "$_"; 5. } 6. my $return_status = close(RUN_MATLAB); 7. unless($return_status) { print STDERR "There was a problem: $?\n" +}
Output sent to the matlab command window is captured to a file. Execution does not get to line 7 until the exit at the end of the matlab script is reached.
However, when I run this on WinXP, the code immediately executes to line 7, instead of waiting until the matlab script completes execution.
I get similar behavior when I replace the piped open with a
or with a$sts = system($matlab_cmd_str);
Is there a way of getting the Linux-like behavior on WinXP, so execution of the Perl script pauses until the matlab script completes?my $stdout = qx/$matlab_cmd_str/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem invoking Matlab from Perl: works on Linux, fails on Windows
by technojosh (Priest) on Oct 02, 2007 at 21:39 UTC | |
|
Re: Problem invoking Matlab from Perl: works on Linux, fails on Windows
by Anonymous Monk on Oct 02, 2007 at 21:14 UTC | |
|
Re: Problem invoking Matlab from Perl: works on Linux, fails on Windows
by arcnon (Monk) on Oct 03, 2007 at 16:52 UTC | |
by jim99 (Initiate) on Oct 10, 2007 at 18:10 UTC |