Exe file with multiple inputs

Hi to all,
I have an exe file named 'sim014-SS-AG.exe'. Each time it is executed, it asks multiple inputs, which after each input the Enter key should be pressed to continue. The inputs for this exe file are as follows:
0 >>'Press Enetr key'
0 >>'Press Enetr key'
sim014-SS-AG.map >>'Press Enetr key'
50 >>'Press Enetr key'
1 >>'Press Enetr key'
iud.ou >>'Press Enetr key'
0 >>'Press Enetr key'
I am about to run this exe file and to enter the input values automatically (NOT manually) in Matlab. How can I do that?
Thanks in advance

 Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Dic. de 2012

0 votos

Try putting all of the inputs into a file, and then using I/O redirection at the MS Windows command line:
CMD> sim014-SS-AG.exe < YourInputFile.txt
If that works, then you can work towards writing files in MATLAB using fopen(), fprintf(), fclose(), and then executing the program using system()

5 comentarios

Coo Boo
Coo Boo el 8 de Dic. de 2012
Editada: Coo Boo el 8 de Dic. de 2012
Thanks, But which format the input file should be? How can I prepare an appropriate input file? Could you give an example using the mentioned inputs?
fid = fopen('YourInputFile.txt', 'wt');
fprintf(fid, '0\n0\nsim014-SS-AG.map\n50\n1\niud.ou\n0\n');
fclose(fid);
system('sim014-SS-AG.exe < YourInputFile.txt')
Coo Boo
Coo Boo el 8 de Dic. de 2012
I ran the file at the MS Windows command line, and it seems to get the inputs from the input file (simple text file) but at the end this message appears:
fmt: end of file apparent state: unit 5 (unnamed) last format: (i6) lately reading sequential formatted external IO
abnormal program termination
Walter Roberson
Walter Roberson el 8 de Dic. de 2012
If you used a text file you constructed in an editor, be sure that you do not end abruptly at the 0 -- make sure you have a newline ("enter") after it like the other lines.
The error message is indicating that it failed to properly read an integer (i6 format). That could be due to the end of line that I mention above, or it might mean that it was expecting another input besides what you gave.
Coo Boo
Coo Boo el 8 de Dic. de 2012
Editada: Coo Boo el 8 de Dic. de 2012
You are right. Thanks a lot

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by