0

How do I call commands in a Matlab terminal when it's opened through Python? I call this:

subprocess.call(["matlab", "-nosplash", "-nodesktop", "-r"], shell=True)

which opens a terminal window. But how can I send new commands in there? I tried simply adding them to the current call, but they don't execute.

sashkello
  • 17,306
  • 24
  • 81
  • 109
  • See http://stackoverflow.com/questions/1567371/wrapping-an-interactive-command-line-application-in-a-python-script, and maybe also http://stackoverflow.com/questions/11457931/running-an-interactive-command-from-within-python – perimosocordiae Jun 11 '13 at 02:37

1 Answers1

1

This worked for me:

subprocess.call(["matlab", "-nosplash", "-nodesktop", "-r", "command1;command2;"], shell=True, stdin=subprocess.PIPE, stout=subprocess.PIPE)
sashkello
  • 17,306
  • 24
  • 81
  • 109