How do i see the printed lines of a .exe file in Matlab?
Mostrar comentarios más antiguos
Hello, i have the following problem: i wrote an test.exe, that i want to start from matlab with the parameter 3. So i use:
system('test.exe 3')
The test.exe has the following code: ...
printf('The parameter was %d!, is it right(y/n)=?',number);
a=getchar();...
So when i start the test.exe from the windows cmd, it will first show me the text and waits for the char.
When i start the test.exe, it will show the text after the char was handed char over.
How can I solve this problem? Is it possible to start the windows cmd from matlab, so i can see the printed lines in the windows cmd window?
Thank you for Help and sorry for the bad english!
6 comentarios
dpb
el 14 de Sept. de 2018
Do you want to interact with the process manually? If so, don't pass the argument.
Fabian Bengl
el 14 de Sept. de 2018
Will if you just pass
!test.exe
will, won't it?
It will also stall Matlab until the process exits.
It will be the DOS console that the text is in, however, NOT the ML command window if that is what you're expecting. There's no way to do the latter.
Fabian Bengl
el 14 de Sept. de 2018
dpb
el 14 de Sept. de 2018
Yeah, but you STILL passed the number in the command line...that's not in the suggested form.
Just use
!test.exe
Fabian Bengl
el 14 de Sept. de 2018
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 15 de Sept. de 2018
1 voto
You will need to use .NET for anything like this in Windows, see https://www.mathworks.com/matlabcentral/answers/414795-run-exe-with-an-input-file-and-close-upon-process-exit. You will need to figure out how you want to deal with standard input and standard output. The point is that with .NET it should be possible to talk interactively with an active process. See also https://www.mathworks.com/matlabcentral/answers/55214-reading-a-pipe-or-ouput-of-a-c-program-into-matlab#answer_315824
If you can rely upon the process always giving back the same prompts and that you do not need to make decisions or record what is sent to you for the purpose of determining what to send, then see also https://www.mathworks.com/matlabcentral/fileexchange/13851-popen-read-and-write
1 comentario
Fabian Bengl
el 15 de Sept. de 2018
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!