capturing stderr && stdout

Betancourt, Josef Josef.Betancourt at GTECH.COM
Wed Nov 3 11:23:24 EST 1999


Agent:
I'm using:
    if on98 :
        program = os.popen(cmdl, 'r')
    elif onNT :
        program = os.popen('( ' + cmdl + ' ) 2>&1', 'r')
    else:   # this assumes Solaris...
        program = os.popen('{ ' + cmdl + '; } 2>&1', 'r')
    
It works,but stdout and stderr are both captured.

-- Josef

> -----Original Message-----
> From: Agent Drek [mailto:drek at MonsterByMistake.Com]
> Sent: Tuesday, November 02, 1999 2:19 PM
> To: python-list at python.org
> Subject: capturing stderr && stdout
> 
> 
> Hullo,
> 
> 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:
> <csh_script>
> #!/bin/csh -f
> 
> #csh stuff goes here
> 
> hscript -q $HIPDIR/$HIPFILE << ENDCAT >>&! $LOG
> 	# now I write hscript commands
> 	opcf /obj
> 	#etc
> ENDCAT
> exit
> </csh_script>
> 
> here's a stripped down version of what I have thus far.
> 
> <python_script>
> #!/usr/local/bin/python
> 
> import os, sys
> HSCRIPT = "hscript"
> 
> p = os.popen("%s" % HSCRIPT, "w")
> p.write("opcd /obj\n")
> p.write("opadd geo\n")
> p.write("opls\n")
> p.write("quit\n")
> </python_script>
> 
> 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 
http://www.sidefx.com/
and check out houdini.

thanks for any tips,

	=derek

Monster By Mistake Inc > 'digital plumber'
mailto:drek at monsterbymistake.com
http://www.interlog.com/~drek
"This mail was powered by Linux & Vim"


-- 
http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list