I have a matlab script that I run from the terminal, that script creates an instance of another program using:

system('cd <path> && mpiexec -n 1 ./<program2> &')

Problem is I don't see any terminal output from program2. (It works if I omit the ampersand, but I need program2 to run in the background). Is it possible to have both the matlab script and program2 output to the same terminal?

  • Hmm, it's not clear at all what MATLAB does if anything with the output from system('cmd&'); I suspect you'll need to find a different way to solve this problem. – thrig Nov 19 '17 at 17:33
  • Perhaps you can add >&/dev/tty to the mpiexec command to make it output to the terminal. – meuh Nov 19 '17 at 17:44
  • @meuh It didn't work. Still no output in terminal. Output works fine if I direct it to a logfile though... '.... ./<program2> > logfile 2>&1 &' – Moody Nov 19 '17 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.