[Tutor] Spawning terminals from Python - A failed question

wormwood_3 wormwood_3 at yahoo.com
Fri Aug 24 23:27:11 CEST 2007


Hello all,

I had this question all written up, then found I had the answer:-) So I decided to share anyway in case anyone found it useful
----------------------------------
I am trying to write a script that will open terminal windows for me, based on certain criteria. In this case, gnome-terminals, in Ubuntu, but my question is more general: How do I launch a command from a script and having it continue running? The pertinent part of my script right now:

# Spawn the 4 terminals, with needed positions and sizes, then exit quietly:
"gnome-terminal --geometry=%dx%d+%d+%d" % (t1width, t1height, t1posx, t1posy)
"gnome-terminal --geometry=%dx%d+%d+%d" % (t2width, t2height, t2posx, t2posy)
"gnome-terminal --geometry=%dx%d+%d+%d" % (t3width, t3height, t3posx, t3posy)
"gnome-terminal --geometry=%dx%d+%d+%d" % (t4width, t4height, t4posx, t4posy)


I need something to pass these lines to of course, to actually launch them. I thought first of the commands module (http://docs.python.org/lib/module-commands.html), but I don't:q
 want to get status or output, I want to basically spawn the process so it keeps running regardless of what the script does next (like running something with " &" after it in linux).
-----------------------------------
All I ended up having to do was:
>>> import commands
>>> commands.getoutput("gnome-terminal")
...
>>>

And the terminal launched. When I closed the interpreter, the terminal stayed open fine. So getoutput() was the ticket.

-Sam




More information about the Tutor mailing list