Run multiple external commands at once in Octave

I am trying to open multiple cygwin terminals and run a .exe file in each of them through octave GUI. I was able to do this in MATLAB, but the exact same code in octave does not work. Code used :

dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_1.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_2.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_3.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_4.sh']);

testtorun_ig1_1 has the command to open a .exe file.

What happens in octave is, initially one cygwin terminal open and runs the .exe file. After the application completes and exits, cygwin terminal closes and opens the next cygwin terminal opens and runs the second .exe files. I want to be able to run 4 cygwin terminals at a time, which is what happens in MATLAB but not in octave

Upvotes: 0

Views: 1031

Answers (1)

Suever
Suever

Reputation: 65430

In Octave, dos waits until the external command completes before executing any more commands.

Octave waits for the external command to finish before returning the exit status of the program in status and any output in text.

If you want to evaluate the external commands asyncronously, you should use the system command with the 'async' input argument

id = system('C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_1.sh', 0, 'async')

Upvotes: 3

Related Questions