Starting terminal applications from within python
Jean-Paul Calderone
exarkun at divmod.com
Thu Feb 2 12:20:02 EST 2006
On 2 Feb 2006 09:01:11 -0800, sleepylight <sleepylight at gmail.com> wrote:
>Hi
>
>I'm staring to learn python for some systems administration projects
>and so far this looks like a really great alternative to using shell
>for everything. The python docs on the web site are really great, but
>I could use come clarification on passing arguments using the
>os.spawnlp() function.
>
>For example, if I run "xterm -e /opt/itt/ncbr/bin/linux/bar" I get an
>xterm executing my nice little test program. However, if I try to run
>that same commad in python it doesn't work so well.
>
>>>> os.spawnlp(os.P_NOWAIT, "/usr/bin/xterm", "/usr/bin/xterm", "-e /opt/itt/ncbr/bin/linux/bar")
Try this:
os.spawnlp(
os.P_NOWAIT,
"/usr/bin/xterm",
"/usr/bin/xterm",
"-e",
"/opt/itt/ncbr/bin/linux/bar")
Each argumnent after the 2nd to spawnlp() is an argument to the program you are running. passing "-e /path" as a single argument is the same as trying to do this on the command line:
xterm "-e /path"
which I think you will find fails in the same way.
Jean-Paul
More information about the Python-list
mailing list