Calling executable and automatically passing input
조회 수: 7 (최근 30일)
이전 댓글 표시
I am using MATLAB to automatically generate a thousand or so slightly different input files for an executable. The executable, when launched, asks for an input file name (in this case, 'test3') and returns an output (in this case, named 'test3.out'). I am using system('FCEA2.exe') to call the relevant executable, and this is where I get stuck--I get the executable appearing in my MATLAB command line asking for the input file name. I can get the script back on track by typing it into the command line, but I want the script to do it automatically so that I can get a thousand answers quickly.
Is there a way to call the FCEA2.exe executable and have MATLAB enter the input file name automatically, without pausing script execution?
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 4월 10일
Yes, you should be able to do this using input redirections and pipes. I am using a mac, so I can use an example from bash, but a similar method will apply for MS Windows. Suppose you have an executable file named myExecutable that takes input from the user. You can directly pass it inputs from the command line using the echo command and pipe
system('echo myInput | myExecutable')
echo command also exists in MS Windows, so hopefully, you will be able to run this line for your *.exe file directly.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!