473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stdout

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
2 1914
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tsai Li Ming | last post by:
Dear all, I have a problem with a redirecting stdout and stderr. I am a top level module and has no control over the imported modules that are making system calls such as os.system or popen2.* ....
4
by: Wes S. | last post by:
How can I redirect and tag sys.stdout values. I tried creating a class module that saved the old stdout and replaced it, but I can't seem to figure out how to do such. Here is what I got... ...
4
by: Leon | last post by:
"stdout" is file object, it open mode is "w" and it have a close() fuction..... while it run close(), how to reopen it because I want to do rewrite it stdout content update
7
by: Mike | last post by:
I would like my 'print' statements to send its output to the user's screen and a log file. This is my initial attempt: class StdoutLog(file): def __init__(self, stdout,...
10
by: Michael Gaab | last post by:
If I redirect stdout by using freopen("afile", "w", stdout); and then I closed stdout using, fclose(stdout), essentially I am just closing "afile". I have to reestablish what stdout originally...
9
by: Santtu Nyrhinen | last post by:
Hi, Let say that I have a function like void writeHello() { printf("Hello"); } Now I need to make an automated test fot that function. The test function returns 1 for successful and 0 for...
2
by: Greg Ercolano | last post by:
When I use os.popen(cmd,'w'), I find that under windows, the stdout of the child process disappears, instead of appearing in the DOS window the script is invoked from. eg: C:\type foo.py import...
5
by: =?gb2312?B?yMvR1MLkyNXKx8zs0cSjrM37vKvM7NHEsru8+7z | last post by:
I wanna print the log to both the screen and file, so I simulatered a 'tee' class Tee(file): def __init__(self, name, mode): file.__init__(self, name, mode) self.stdout = sys.stdout...
4
by: hg | last post by:
Hi, I have the following ********************* C extention - redir.c #include "Python.h" PyObject * test_redir_test(PyObject *self) {
5
by: Joakim Hove | last post by:
Hello, I have written a program in C; this programs uses an external proprietary library. When calling a certain function in the external library, the particular function writes a message to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.