2

I have to execute a standalone application, aTool.exe, from a .m file, Gen.m.
I put a command in Gen.m to execute the aTool.exe as

system('aTool.exe');

It worked fine. However, because aTool.exe has a lot of printings to the command window, it takes forever to finish running this command. I wrote the Gen.m. The "aTool.exe" is an open source application so I do no have access to the source codes. aTool.exe is supposed to generate 3 text files, Result1.txt, Result2.txt and Result3.txt at the end. When it runs, it prints out some processing messages to the screen. Those three text files are what I need but I don't need those processing messages during the running time.

Does any one know how I can stop "aTool.exe" printing to the command window when I run the Gen.m file ? I have tried

matlab -nodisplay -nojvm -nosplash -nodesktop -r Gen > matlab.out

It didn't work. The command window still popped out and started printing.

Cassie
  • 1,179
  • 6
  • 18
  • 30
  • Some people have just [the opposite problems](http://stackoverflow.com/questions/12629742/output-from-fortran-application-not-showing-up-in-matlab/12650462#12650462) :) is it stdout or stderr that is printed, do you know? – angainor Oct 02 '12 at 05:34
  • Perhaps [this](http://stackoverflow.com/questions/1262708/suppress-command-line-output) helps? – Colin T Bowers Oct 02 '12 at 08:54

1 Answers1

1

You can capture the output in a variable using system's output arguments. This'll let you check for errors and maybe extract useful bits from the output too. As long as you use the semicolon to suppress echoing, it won't be displayed on the command window.

[status,result] = system('aTool.exe');

Or I think you could discard its output using redirection inside the system call.

system('aTool.exe > NUL');

Capturing the output in the first manner will make debugging easier in the long run. But if it's really a ton of output, you might end up buffering a lot of data.

Andrew Janke
  • 23,508
  • 5
  • 56
  • 85
  • Thank you very much. I am sorry that I didn't elaborate clearly. I revise my question a little bit above. By using the command "system('aTool.exe > NUL')", it did stop printing out the message to the screen. However, it stopped to generate those 3 text files I need either. Is there anyway to still have those 3 files at the end without having those processing messages during the run ? – Cassie Oct 02 '12 at 18:39