0

Typing the command in my ubuntu terminal recognizes the parameter t in my command:

/home/daniel/Downloads/SALOME-7.6.0-UB14.04/salome start -t

What is the difference when starting the same process in python via Popen?

command ='/home/daniel/Downloads/SALOME-7.6.0-UB14.04/salome'
commandargs= 'start -t'

import subprocess
subprocess.Popen([command, commandargs], shell=True).wait()

My parameter stands for terminal mode but running my application (salome) via python Popen opens the GUI.

daniel
  • 28,673
  • 36
  • 87
  • 145
  • In `/home/daniel/Downloads/SALOME-7.6.0-UB14.04/salome start -t`, "start" and "-t" are two separate arguments, so they belong as two different list items in the args list (also no point in using `shell=True` in this case) – Colonel Thirty Two Apr 28 '16 at 21:22
  • use your commandargs like this: `commandargs= ['start', '-t']` – arne.z Apr 28 '16 at 21:28

1 Answers1

0

See: https://docs.python.org/3.5/library/subprocess.html#subprocess.Popen

args should be a sequence of program arguments or else a single string. 


See also: https://stackoverflow.com/a/11309864/2776376

subprocess.Popen([command, commandargs.split(' ')], shell=True).wait()

alternatively you could do, although less recommended:

subprocess.Popen(command + commandargs, shell=True).wait()

should do the trick

Community
  • 1
  • 1
Maximilian Peters
  • 24,648
  • 11
  • 64
  • 80
  • `subprocess.Popen((command+' '+ commandargs).split(' '), shell=True).wait()` would be correct, but I have the same problem – daniel Apr 28 '16 at 21:23