Starting terminal applications from within python

S

sleepylight

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.

usage: /usr/bin/xterm [-/+132] [-C] [-Sccn] [-T string] [-/+ah]
[-/+ai]
[-/+aw] [-b number] [-/+bc] [-bcf milliseconds] [-bcn milliseconds]
[-bd color] [-/+bdc] [-bg color] [-bw number] [-/+cb] [-cc
classrange]
[-/+cjk_width] [-class string] [-/+cm] [-/+cn] [-cr color] [-/+cu]
[-/+dc]
[-display displayname] [-e command args ...] [-fa pattern] [-fb
fontname]
[-/+fbb] [-/+fbx] [-fd pattern] [-fg color] [-fi fontname] [-fn
fontname]
[-fs size] [-fw fontname] [-fwb fontname] [-fx fontname] [%geom]
[#geom]
[-geometry geom] [-hc color] [-help] [-/+hold] [-iconic] [-/+ie]
[-/+im]
[-into windowId] [-/+j] [-/+k8] [-kt keyboardtype] [-/+l] [-/+lc]
[-lcc path] [-leftbar] [-lf filename] [-/+ls] [-/+mb] [-mc
milliseconds]
[-/+mesg] [-/+mk_width] [-ms color] [-n string] [-name string] [-nb
number]
[-/+nul] [-/+pc] [-/+pob] [-rightbar] [-/+rv] [-/+rvc] [-/+rw]
[-/+s]
[-/+samename] [-/+sb] [-/+sf] [-/+si] [-/+sk] [-sl number] [-/+sm]
[-/+sp]
[-/+t] [-ti termid] [-title string] [-tm string] [-tn name] [-/+u8]
[-/+ulc] [-/+ulit] [-/+ut] [-/+vb] [-version] [-/+wc] [-/+wf]
[-xrm resourcestring] [-ziconbeep percent]

Type /usr/bin/xterm -help for a full description.


I thought maybe I needed a space before the '-e' for some reason, but
that didn't really help:
So, I guess that I'm not reading how to set up the arguments to
spawnlp() correctly. Does anyone else have some experience with this?
 
S

sleepylight

Ah! I see now. That makes prefect sense. I guess I was thinking that
python was simply going to pass a whole command string to the program
rather than give each argument as individual strings. Seeing this
makes the documentation seem much more sensible. Thank you!
 
J

Jorgen Grahn

Ah! I see now. That makes prefect sense. I guess I was thinking that
python was simply going to pass a whole command string to the program
rather than give each argument as individual strings. Seeing this
makes the documentation seem much more sensible. Thank you!

[offtopic]

You might also want to look into using the screen(1) utility. I have found
that doing "screen foo" (from within a screen session) is often a superior
way to achieve the things people often use "xterm -e foo" for. Especially if
they have scripts pop up lots of applications in separate terminals.

/Jorgen
 

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top