passing multiple inputs to .exe via system or dos

9 views (last 30 days)
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
per isakson on 31 Mar 2015
"host of other ways" &nbsp Did you try /r instead of \r? Option in "DOS" are typically preceded by /

Sign in to comment.

Accepted Answer

per isakson
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';
However, I didn't try that for a very long time. See Using command redirection operators
  1 Comment
Chad Greene
Chad Greene on 28 Mar 2015
Brilliant; tremendous thanks, Per! The working solution:
parameters = [2007 10 10 25 33]';
dlmwrite('parameters.txt',parameters)
system('solid.exe < parameters.txt');
Thank you very much!

Sign in to comment.

More Answers (0)

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!