How could I write into the command prompt window of windows 7 with my matlab script?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Albert
el 31 de Ag. de 2015
Comentada: Albert
el 1 de Sept. de 2015
Hello,
I'm trying to write a line into my command prompt window of Windows 7 with a matlab script, it can open it well but I didn't find how to write in it and simulate 'enter'. Would anyone know how to do that? Thank you in advance!
Lance_filename = 'Script.txt';
Input_filename = 'filename.txt';
fid = fopen(Lance_filename,'w');
script=sprintf('App.exe %s',Input_filename);
fwrite(fid,script,'char');
fclose(fid);
!cmd
%!cmd < Script.txt
%system('cmd.exe &');
0 comentarios
Respuesta aceptada
Albert
el 31 de Ag. de 2015
2 comentarios
Walter Roberson
el 31 de Ag. de 2015
I do not understand why you bother creating a file to use as input to cmd.exe when you could just system() the command directly. For example with what you have written you could use
system( sprintf('App.exe "%s"', Input_filename) );
and if it is waiting for any input to proceed you could
system( sprintf('App.exe "%s" < NUL:', Input_filename) );
Más respuestas (2)
Ver también
Categorías
Más información sobre Debugging and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!