Continue after .exe finishes
조회 수: 5(최근 30일)
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.
Joel Lynch 2021년 6월 9일
편집: Joel Lynch 2021년 6월 9일
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...