Effacer les filtres
Effacer les filtres

Running .exe file from MTLAB using system() and Wait until the program closes

5 vues (au cours des 30 derniers jours)
abbas jalilian
abbas jalilian le 25 Sep 2017
Commenté : abbas jalilian le 17 Oct 2017
Hi everyone,
I use system to run my executable file:
system('myfile.exe')
How to determine that the program was closed? I want MATLAB to run the next line after closing the execution program. Thanks

Réponses (2)

dpb
dpb le 25 Sep 2017
>> help system
system Execute system command and return result.
[status,result] = system('command') calls upon the operating system to
execute the given command. The resulting status and standard output
are returned.
...
continue reading for further details...
  1 commentaire
abbas jalilian
abbas jalilian le 17 Oct 2017
Thank you for your answer But my problem has not yet been resolved I've written a program with Processing and when I run it, MATLAB instantly runs the next lines.

Connectez-vous pour commenter.


Joao
Joao le 28 Sep 2017
I have a similar issue, but in my case the variables status / result are not updated when the executable finishes. It seems to me that these variables are in place to indicate the status of the call to the system function not its output! Any further ideas would be much appreciated!
  2 commentaires
Steven Lord
Steven Lord le 28 Sep 2017
You should probably post this as a separate question, not as an answer on another question. If you do post as a separate question please show the exact line of code you use to call your executable, state what you observed when you executed that line of code, and explain what you expected that line of code to do (referencing parts of that code).
dpb
dpb le 28 Sep 2017
The status is command status; whether it was/was not executed w/o error. The result returned is dependent upon the executed command using stdout for whatever output it returns. Also if you use the trailing ampersand '&' when submitting the command the result output is not updated and status is the status on launching the background session, not on completion.
It can be illustrated to work with command that is known to behave using stdin/stdout; not every console program you may try to execute follows those rules--
>> [stat,res]=system('cd') % simple command w/ known output...
stat =
0
res =
C:\ML_R2014b\work
>> [stat,res]=system('cd:') % oopsies, made a typo...
stat =
1
res =
The filename, directory name, or volume label syntax is incorrect.
>>

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by