By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,904 Members | 1,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,904 IT Pros & Developers. It's quick & easy.

Stdout

P: n/a
Dear Users,

I am trying to recover through the python function
popen3 the stdout,in,err of a launched process.

I would like also to recover the stdout which you can
get only through the command: command1 >& filename

Do you know how I can access to that stdout by python?

Thanks

GIacomo

Apr 14 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Apr 14, 2:49 am, gbast...@pasteur.fr wrote:
Dear Users,

I am trying to recover through the python function
popen3 the stdout,in,err of a launched process.

I would like also to recover the stdout which you can
get only through the command: command1 >& filename

Do you know how I can access to that stdout by python?
I'm not sure if I understand your entire post, but in python, you get
access to stdout through the sys module:
>>print 'hello, world!'
hello, world!
>>import sys
sys.stdout.write('hello, world!')
hello, world!
>>>
Thanks

GIacomo

Apr 14 '07 #2

P: n/a
gb******@pasteur.fr wrote:
Dear Users,

I am trying to recover through the python function
popen3 the stdout,in,err of a launched process.

I would like also to recover the stdout which you can
get only through the command: command1 >& filename

Do you know how I can access to that stdout by python?

Thanks

GIacomo
Check out module "subprocess" which is meant to replace function "popen3":

pr = subprocess.Popen(["command", "-option1", "-option2"], stdin =
subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE,
bufsize = 0, close_fds = True)

# And then:
line = pr.stdout.readline()
print line
pr.stdin.write("hello to command")

HTH

H.
Apr 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.