passing multiple inputs to .exe via system or dos
9 views (last 30 days)
Show older comments
I'm trying to pass a series of inputs to an executable via the system command, but in every way I've tried to run it, I'm prompted to manually input values in the command window. I need to run this program several hundred times, so I'd rather not enter parameters manually. The program is called solid.exe and is available here if you're feeling compelled to give it a shot.
To get solid earth tide estimates for March 12, 2005 at (65°N,123°E), I've tried
system('solid.exe 2005 3 12 65 123')
and
s = sprintf('solid.exe %s \r %s \r %s \r %s \r %s','2005', '3','12','65','123');
system(s);
and a whole host of other ways to concatenate strings. No matter what I try, the command window still wants manual data entry. I can simply type
system('solid.exe')
and when I enter parameters, it takes a fraction of a second for the program to run. How can I automate this to compute a series of lat, lon and times?
1 Comment
per isakson
on 31 Mar 2015
"host of other ways"   Did you try /r instead of \r? Option in "DOS" are typically preceded by /
Accepted Answer
per isakson
on 27 Mar 2015
Edited: per isakson
on 29 Mar 2015
My system don't want me to download solid.exe.
I guess you are on Windows, since you mention dos. Furthermore, I guess the problem is with solid.exe. Is there a manual?
The input argument of system is just a string value. I usually
- experiment in the "dos-window" to figure out how to call the external program, solid in your case
- copy&paste the successful command string, cmd_str, to Matlab
- run system(cmd_str) from Matlab
If the external program doesn't ask for arguments in the dos-window it should not do it when run from Matlab.
If successful so far I generate cmd_str automatically.
If not successful, I would write the arguments to responsefile.txt and try something like
cmd_str = 'solid.exe < responsefile.txt';
More Answers (0)
See Also
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!