Running an .exe file with multiple inputs
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
So I'm trying to run a .exe file called gridconv.exe. Insert is the multiple areguements that I am trying to get the code to run requentially after each other
insert= 'mdata input y n dataset tecplot output n n dim fcn 1 n n';
system('"gridconv.exe" insert');
So the .exe file works by asking a question then you submit an answer and press enter. Then it goes to the next prompt etc about 10 times. The responses to these answers is the above 'insert'. However it is not running the program this way. In my main matlab window it's still asking I manually submit each answer then submit enter. How do I get this to automatically take the arguments.
0 Kommentare
Antworten (1)
Walter Roberson
am 31 Aug. 2015
insertwords = regexp(insert, '\s+', 'split');
tfile = tempname();
fid = fopen(tfile, 'wt');
fprintf(fid, '%s\n', insertwords{:});
fclose(fid);
system( sprintf('%s < "%s"', 'gridconv.exe', tfile);
delete(tfile);
This presumes that every "word" should go on a different line. If that is not the case then you need to use a delimiter between the parts and code that delimiter in the regexp, or you need to code the lines using a cell array of strings.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!