capturing stderr && stdout

Agent Drek drek at MonsterByMistake.Com
Tue Nov 2 20:18:47 CET 1999


I have searched the web and all the python documents/examples I could find
before posting here. My apologies if I have missed the obvious :) (I bought
two books as well that I am going through)

Alot of what I need to do with python depends on launching and controlling
a subprogram called hscript. It's a 'closed' application that is not a full
bodied language like python. I am hoping to launch one instance of hscript
write to it and keep its stdout && stderr.

Most of our work gets done with csh scripts like the following:
#!/bin/csh -f

#csh stuff goes here

hscript -q $HIPDIR/$HIPFILE << ENDCAT >>&! $LOG
	# now I write hscript commands
	opcf /obj

here's a stripped down version of what I have thus far.


import os, sys
HSCRIPT = "hscript"

p = os.popen("%s" % HSCRIPT, "w")
p.write("opcd /obj\n")
p.write("opadd geo\n")

This is great so far but I just need stderr from hscript (just in case it
crashes:) and stdout (to keep a neat log file)

This will need to work on *nix.

I'm trying to move to python as our main scripting language so that we can
reuse code and integrate a gui (tkinter) easily into our apps.

If you're interested in what hscript is you can visit
and check out houdini.

thanks for any tips,


Monster By Mistake Inc > 'digital plumber'
mailto:drek at
"This mail was powered by Linux & Vim"

More information about the Python-list mailing list