subprocess - multiple "gnome-terminal" with python issue -
i writing python program runs following:
import subprocess import time def fun1(): terminal1 = ['gnome-terminal'] terminal1.extend(['-x', 'sh', '-c', '"roscore"']) pid = subprocess.popen(terminal1, stdout=subprocess.pipe) time.sleep(3) print "success1" fun2() def fun2(): terminal2 = ['gnome-terminal'] terminal2.extend(['-x', 'sh', '-c', '"rosrun rosserial_python serial_node.py /dev/ttyacm0"' ]) pid2 = subprocess.popen(terminal2, stdout=subprocess.pipe) print "success2" fun1() fun1 works properly, wait 3 seconds because lasts sometime until done fun2 can work (i can't launch both simultaneously, fun2 has wait fun1, never ends before fun2)
the problem comes when running fun2, don't know mistake, "same" code in fun1, gnome-terminal appears few milliseconds , disappears...
any suggestion??
thank in advance
the issue ". don't need use these when passing list of params subprocess. escaped before being run.
the window closing because generated command malformed , generates error , exits immediately.
so if have literal command want run, can use shlex.split generate appropriate list pass subprocess. usually, don't have worry quotes , escape characters. pass space argument, write space.
Comments
Post a Comment