Calling executable and automatically passing input
7 views (last 30 days)
Show older comments
Alex Dworzanczyk
on 10 Apr 2020
Commented: Alex Dworzanczyk
on 10 Apr 2020
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 Comments
Accepted Answer
Ameer Hamza
on 10 Apr 2020
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.
More Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!