473,408 Members | 1,699 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,408 software developers and data experts.

Is there a limit to os.popen()?

I'm not sure the proper way to phrase the question, but let me try.

Basically, I'm working with a script where someone wrote:

kr = string.strip(os.popen('make kernelrelease').read())
And then searches kr to match a regular expression.

This seems to have been working, however lately when this line executes
I get a number of messages to stderr after several minutes of execution:

cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
I know the output from this make has been growing (make applies some
patches and the patch list is growing). Does os.popen() have some kind
of read buffer limit that i'm hitting which is causing things to break?


--

Carl J. Van Arsdall
cv*********@mvista.com
Build and Release
MontaVista Software

Jul 11 '06 #1
6 2338
Hello,

I'm not 100% sure on this but to me it looks like there is a problem in
your make file. I would look in there first, see where 'cat' is
executed, I bet your problem will be around there.

Hope this helps,

Colin

Carl J. Van Arsdall wrote:
I'm not sure the proper way to phrase the question, but let me try.

Basically, I'm working with a script where someone wrote:

kr = string.strip(os.popen('make kernelrelease').read())
And then searches kr to match a regular expression.

This seems to have been working, however lately when this line executes
I get a number of messages to stderr after several minutes of execution:

cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
I know the output from this make has been growing (make applies some
patches and the patch list is growing). Does os.popen() have some kind
of read buffer limit that i'm hitting which is causing things to break?


--

Carl J. Van Arsdall
cv*********@mvista.com
Build and Release
MontaVista Software
Jul 11 '06 #2
cdecarlo wrote:
Hello,

I'm not 100% sure on this but to me it looks like there is a problem in
your make file. I would look in there first, see where 'cat' is
executed, I bet your problem will be around there.

Hope this helps,

Colin

Well, running the make on the command line seems to work just fine, no
errors at all. I, in fact, get the results I expect with no error
messages printed out. I thought maybe something might have used cat as
a utility, thanks, i'll keep on it.

-c

--

Carl J. Van Arsdall
cv*********@mvista.com
Build and Release
MontaVista Software

Jul 11 '06 #3
kr = string.strip(os.popen('make kernelrelease').read())
If make is being executed, I presume that the python script has rw
access to the location. How about

x=os.system("make kernelrelease my_report 2>&1 ")
kr=open("my_report").read()
Just a blind throw.

Good luck
sree
Jul 11 '06 #4
In article <ma***************************************@python. org>,
"Carl J. Van Arsdall" <cv*********@mvista.comwrote:
>Well, running the make on the command line seems to work just fine, no
errors at all.
What about running it as

make kernelrelease | cat

This way the output goes to a pipe, which is what happens when it's
called from your script. Do you see those "broken pipe" messages after a
few minutes in this case?
Jul 11 '06 #5
Lawrence D'Oliveiro wrote:
In article <ma***************************************@python. org>,
"Carl J. Van Arsdall" <cv*********@mvista.comwrote:

>Well, running the make on the command line seems to work just fine, no
errors at all.

What about running it as

make kernelrelease | cat

This way the output goes to a pipe, which is what happens when it's
called from your script. Do you see those "broken pipe" messages after a
few minutes in this case?
Alright, so I tried that line in the interpreter and got the same
problem. So let me quickly state what I know, and what I'm starting to
infer.

Anyhow, running make on the command line gives me no problems. There
are cats all over the makefile, I checked, but I don't seem to have any
problems on the command line. Now, when attempting to run this make in
python things seem to go alright, except I get tons of errors dumped to
the screen, its very confusing. I don't know too much about pipes
though or how exactly to go about debugging this. Could it be something
like, make's output is piped correctly but pipes used by cat within the
makefile get screwed up inside python somehow?

-c


--

Carl J. Van Arsdall
cv*********@mvista.com
Build and Release
MontaVista Software

Jul 11 '06 #6
In article <ma***************************************@python. org>,
"Carl J. Van Arsdall" <cv*********@mvista.comwrote:
>Lawrence D'Oliveiro wrote:
>In article <ma***************************************@python. org>,
"Carl J. Van Arsdall" <cv*********@mvista.comwrote:

>>Well, running the make on the command line seems to work just fine, no
errors at all.

What about running it as

make kernelrelease | cat

This way the output goes to a pipe, which is what happens when it's
called from your script. Do you see those "broken pipe" messages after a
few minutes in this case?
Alright, so I tried that line in the interpreter and got the same
problem.
No, I wanted you to try it from a bash command prompt, to try to
simulate the environment when the make command on its own is invoked via
popen.
Jul 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stuart McGraw | last post by:
When I run (Python 2.3.3) this script on a MS Windows 2000 machine: import os print "1st popen..." f = os.popen ("echo " + u"\u0054\u0045\u0053\u0054.txt") print f.read () print "2nd popen..."...
17
by: bastiaannaber | last post by:
I am trying to write a program which uses popen but I have a problem. I want to detect if the program I call with popen has ended. For example: #include <stdio.h> #include <sys/types.h>...
2
by: Maarten van Veen | last post by:
A long story made short, I've build a python/cgi website consisting of two pages. Page1 has a html form in which you can input a series of queries. Then via Popen it starts a pythons search script,...
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...
3
by: Jesse | last post by:
Hi all, I have a problem using wget and Popen. I hope someone can help. -- Problem -- I want to use the command: wget -nv -O "dir/cpan.txt" "http://search.cpan.org" and capture all it's...
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
15
by: Daniel Klein | last post by:
I'm trying to get popen to work on Windows. Here's a simplified example of what I'm trying to get working: I have a hw.c program as follows: #include <stdio.h> main() { printf ("Hello...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
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,...
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...
0
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...

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.