zoidbergi zoidbergi - 2 years ago 73
Python Question

difference between terminal execution and popen

Typing the command in my ubuntu terminal recognizes the parameter

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.

Answer Source

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: http://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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download