0

I have a batch file that starts an executable that is supposed to

  1. Run a Matlab script and wait until it stops
  2. Run an exe that does some work, print some output, and saves some data to disk and wait until it stops
  3. Run another Matlab script

Item number one works fine. Item number two does not show console output. How can I fix that.

This is my script

start /wait matlab -r start.m
start /wait "c/hello.exe"
start matlab -r finish.m
ToniAz
  • 430
  • 1
  • 6
  • 24
  • It doesn't show output or it never gets executed? Do you have an `exit()` call at the end of `start.m`? – Suever Mar 13 '16 at 19:47
  • @Suever There is an exit in both m files. The exe does not show terminal output nor does it write a file. So I cannot tell if it executed or not (probably not) – ToniAz Mar 13 '16 at 19:51
  • Can you put a print statement at the end of the MATLAB script to make sure it finishes? It could be that it is erroring out. – Suever Mar 13 '16 at 19:52
  • @Suever the matlab files are running at the same time, hence the exe is running too because it's in the middle – ToniAz Mar 13 '16 at 19:54
  • That `/wait` you have in there ensures that they *aren't* running at the same time. Each one will not be executed until the previous one exits. – Suever Mar 13 '16 at 19:57
  • @Suever This is not what is going on. All three items are running together. – ToniAz Mar 13 '16 at 20:02
  • [You have to use the `-wait` parameter](http://stackoverflow.com/questions/35687254/run-matlab-commands-one-by-one-on-windows-using-bat-file/35687469#35687469) – Daniel Mar 13 '16 at 20:06
  • But you *want* it to wait? What about using the [`-wait` input](http://stackoverflow.com/questions/14495/how-can-i-stop-matlab-from-returning-until-after-a-command-line-script-completes) to MATLAB? – Suever Mar 13 '16 at 20:06
  • @Suever I want to run 1 and wait for it to finish then move on to 2, run 2 and wait for it to finish then move on to 3, then run 3 – ToniAz Mar 13 '16 at 20:11
  • @ToniAz: Then you have to use the -wait parameter. – Daniel Mar 13 '16 at 20:34
  • 1
    `start "My Title" /b /wait "c:\hello.exe"` First set of quotes are Window Title. Your file path is wrong. You'll need `/b` as well. See `start /?`. This is all you actually require `"c:\hello.exe"`. –  Mar 13 '16 at 22:24

0 Answers0