Effacer les filtres
Effacer les filtres

Running an .exe file with multiple inputs

6 vues (au cours des 30 derniers jours)
Crystal Green
Crystal Green le 31 Août 2015
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.

Réponses (1)

Walter Roberson
Walter Roberson le 31 Août 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.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by