Calling executable and automatically passing input

7 vues (au cours des 30 derniers jours)
Alex Dworzanczyk
Alex Dworzanczyk le 10 Avr 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?

Réponse acceptée

Ameer Hamza
Ameer Hamza le 10 Avr 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.

Plus de réponses (0)

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by