Filter löschen
Filter löschen

Continue after .exe finishes

12 Ansichten (letzte 30 Tage)
SamiamO
SamiamO am 9 Jun. 2021
Bearbeitet: Walter Roberson am 10 Jun. 2021
Hi,
I am running an external .exe file that returns something to the matlab command line once it has finished. I would like to use this in an optimization but currently the enter key needs to be pressed in the command line in order for the .exe to close and then for the matlab code to continue.
Here's how i'm calling the .exe: eval(['!program',tempfilename]);
Is there a way I can continue after it has finished? I have tried a timer and the java robot, but neither seem to work.
Thanks,
  1 Kommentar
Rik
Rik am 9 Jun. 2021
You will have to find a way to get your program to work without interaction.
Also, why aren't you using system instead of eval?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Joel Lynch
Joel Lynch am 9 Jun. 2021
Bearbeitet: Joel Lynch am 9 Jun. 2021
You can use system() function to pass the command (as a string) without the "!" symbol. If using unix OS, you can pipe (with the | character) a newline character entry ( with echo -e '\n') to a program. System will wait until both commands are completed. Note: the double apostrophes around \n are needed as escape characters and print an apostrophe.
system(['echo -e ''\n'' | ',some_exe_str]);
Not sure if using Windows...
  8 Kommentare
Rik
Rik am 9 Jun. 2021
Or with the double quote:
status = system( [ 'echo. | program "' tempfilename '"'] );
SamiamO
SamiamO am 10 Jun. 2021
Thanks all, working perfectly now! - also the period is not necessary, thanks for pointing that out.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by