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 2 1925
On Apr 14, 2:49 am, gbast...@pasteu r.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.wr ite('hello, world!')
hello, world!
>>>
Thanks
GIacomo
gb******@pasteu r.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.Pope n(["command", "-option1", "-option2"], stdin =
subprocess.PIPE , stdout = subprocess.PIPE , stderr = subprocess.PIPE ,
bufsize = 0, close_fds = True)
# And then:
line = pr.stdout.readl ine()
print line
pr.stdin.write( "hello to command")
HTH
H. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.* . I have tried the simplest
method of capturing stdout, stderr via:
saveout = sys.stdout
sys.stdout = file_obj
|
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...
class cStdOutRedirect :
stdOld = ""
def __main__(self) :
stdOld = sys.stdout
|
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
|
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, name='/tmp/stdout.log',
mode='w',bufsize=-1):
super(StdoutLog, self).__init__(name,mode,bufsize)
self.stdout = stdout
|
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 pointed to?
thanks
| |
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 unsuccessful test.
int Test_writeHello() {
|
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 os
import sys
file = os.popen("nslookup", 'w')
file.write("google.com\n")
file.close()
|
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
sys.stdout = self
|
by: hg |
last post by:
Hi,
I have the following
********************* C extention - redir.c
#include "Python.h"
PyObject * test_redir_test(PyObject *self) {
|
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 stdout. I am not
particularly interested in this message, and would like to silence it
- however I do not know how to do it. (I stdout and stderr my self, so
just redirecting into oblivion is not an option).
An excerpt of the code looks like this:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |