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?

采纳的回答

Ameer Hamza
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 CenterFile Exchange 中查找有关 Entering Commands 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by