I'm trying to understand how popen2 works. Found in this group, that
popen2.popen2 can cause trouble so i chose win32pipe.popen 2.
have a look a the listing of 2 files:
ekmain.py:
**************
import win32pipe
(stdin1, stdout1) = win32pipe.popen 2("test1.py")
stdin1.write("1 \n")
print stdout1.readlin es() # This will print the result.
**************
test1.py:
**************
a=raw_input("a= ")
print "***a=",a
print "finished!"
**************
i do not understand, why ekmain.py produces only following output:
['a=']
why is the stdin1.write("1 \n") command ignored?
i tried to find an answer in this group by searching through existing
article, but i had no success.
tanks for you help!
ernst
p.s.: i working with python 2.3 on win2000. 1 1803
At Monday 15/1/2007 07:24, diego wrote:
>I'm trying to understand how popen2 works. Found in this group, that popen2.popen 2 can cause trouble so i chose win32pipe.popen 2.
have a look a the listing of 2 files: ekmain.py: ************ ** import win32pipe
(stdin1, stdout1) = win32pipe.popen 2("test1.py") stdin1.write(" 1\n") print stdout1.readlin es() # This will print the result. ************ **
test1.py: ************ ** a=raw_input("a =") print "***a=",a print "finished!" ************ **
i do not understand, why ekmain.py produces only following output: ['a=']
why is the stdin1.write("1 \n") command ignored?
Using popen4 instead of popen2 we get stderr too, and there is a traceback:
['a=Traceback (most recent call last):\n', ' File
"C:\\TEMP\\test 1.py", line 1,
in ?\n', ' a=raw_input("a= ")\n', 'EOFError: EOF when reading a line\n']
Using "python test1.py" as the popen4 argument we get the expected result:
C:\TEMP>main.py
['a=***a= 1\n', 'finished!\n']
(I don't know why)
>p.s.: i working with python 2.3 on win2000.
I used 2.4 on XPSP2.
--
Gabriel Genellina
Softlab SRL
_______________ _______________ _______________ _____
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Doug |
last post by:
This works with a small string, but not a large one (read returns an
empty string if i pass a large html file to tidy):
>>> iin , iiout = popen2("tidy.exe -asxml")
>>> iin.write(str)
>>> iin.close()
>>> iiout.read()
''
|
by: A. Lloyd Flanagan |
last post by:
OK, I've got a weird one I haven't been able to figure out yet.
Admittedly I haven't had time to dig into the library source, but this
behavior certainly doesn't seem right. Here's a test case:
"""Test program to demonstrate problem with popen2 module."""
import popen2
def main (argv):
mycmd = 'python2.3 -c "for i in range(100000):\n print i"'
p = popen2.Popen3(mycmd)
|
by: Chris S. |
last post by:
A wrote a small class to handle IO through pipes, but the connection
only seems to work in one direction. The following code defines
connection.py, engine.py, and controller.py. Once connected, the engine
is only able to send and the controller recieve. Also, this only works
when using popen2.popen3. Using os.popen3 doesn't work at all and seems
to behave completely differently.
What could be causing these problems? Any help is greatly...
|
by: Jakob Simon-Gaarde |
last post by:
Follow-up on a thread from 1999 (see below)
Well now it is 2005 and the operating system I'm using is Windows
Server 2003, and I can still see that the same problem persists with:
win32pipe.popen2()
win32pipe.popen3()
win32pipe.popen4()
while win32pipe.popen() does almost what you want.
|
by: Magnus Lycka |
last post by:
I'm trying to read standard out in a process started with popen2
in a non-blocking way. (Other good ways of doing this than the
one I tried are appreciated.)
I've tried to dumb down my code to see what happens, and
socket.poll seems to behave very strangely. I've tried to
use the .poll method for the poll object with and without
a timeout, but in either case, the output randomly switches
between on of the versions below. It runs fast,...
| |
by: Xah Lee |
last post by:
Python Doc Problem Example: os.system
Xah Lee, 2005-09
today i'm trying to use Python to call shell commands. e.g. in Perl
something like
output=qx(ls)
in Python i quickly located the the function due to its
|
by: mapik.ua |
last post by:
Hi. I have such problem with os.popen2 function:
//test.py file
#!/usr/local/bin/python
print "start"
x= raw_input()
print "end"
//main.py file
#!/usr/local/bin/python
|
by: Martin P. Hellwig |
last post by:
Hi all,
I was doing some popen2 tests so that I'm more comfortable using it.
I wrote a little python script to help me test that (testia.py):
---------------------------------
someline = raw_input("something:")
if someline == 'test':
print("yup")
|
by: mikem76 |
last post by:
How do I automatically redirect stdout and stderr when using os.popen2
to start a long running process. If the process prints a lot of stuff
to stdout it will eventually stop because it runs out of buffer space.
Once I start reading the stdout file returned by os.popen2 then the
process resumes. I know that I could just specify > /dev/null when
starting the process but I'd like to know if there is a way to start a
process using os.popen2...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
| |