Continue matlab while a dos/system command is executed / close dos window
Show older comments
I have to use a dos-Programm where I don't have the source code. This programm controlls some measurement device via ftp.
To start the programm I call it by
answer = dos(['my_programm.exe', optionsstring])
The programm produces periodic output that is print to the matlab command window.
It runns until it is stopped by calling another exe (which writes something into a file that is read by the first...)
answer = dos(['my_end_programm.exe', optionsstring])
This works fine, if the two dos-comands are executed in a callback of a gui in Matlab2014a! Execution of 'my_programm.exe' does not block matlab. The gui stays aktive and I can press some button that triggers the 'end'-command.
However in matlab 2019b this does not work any more. The dos-command seems to block matlab. matlab waits until 'my_programm.exe' ends - which does not happen.
Also in 2014a when called from a scipt - no gui-callback - matlab gets blocked by the dos command.
Is there a way around this? Preferable in matlab 2019b or 2020?
As a workaround I use the option '&' in 2014:
answer = dos(['my_programm.exe', optionsstring, ' &'])
This opens a dos console window. The output of 'my_programm' gets there - which is aceptabel - but the window stays open. Since I call 'my_programm.exe' a couple of times this gets messy.
How can i close the dos console window?
Thank you for any help!
6 Comments
Ameer Hamza
on 14 May 2020
Try to use system() function instead of dos().
Rik
on 14 May 2020
@Ameer, I have alway thought those were equivalent if run on a Windows machine. I can't find anything in the doc suggesting otherwise. Have you come across a difference?
Ameer Hamza
on 14 May 2020
No, I didn't found any difference. That was just a guess. The least it did is to bring this question up in recent activity so that someone who knows this stuff can answer xD
Btw, can you point to the documentation page for the start() you mentioned in your answer? There are several start() functions for different classes, and I couldn't find the one related to running external programs from MATLAB.
Ameer Hamza
on 14 May 2020
Ok. I misunderstood it to be a MATLAB function. Thanks for the information.
Joachim
on 27 May 2020
Accepted Answer
More Answers (0)
Categories
Find more on Parallel and Cloud in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!