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

popen2 question

I'm using popen2 and getting an extra 1 at the end of my output. I didn't
see where this was explained in the docs so I clearly don't understand the
behavior. My code is simple.

(input, output) = os.popen2('whackyperlprogram')
results = output.read()
rc = output.close()
print results

The documentation said that the return code would returned with the stdout
handled was closed.

This does not explain why I am getting a '1' appended to the end of the
results.

And yes, there is some functionality bundled in a perl program that I need
-- and I don't have time to reimplement what was written in perl. When I
run the perl code directly, I get the output I want. When I run it through
the os.popen2 module, I get an additional 1 appended. (It's all string
output)

Is this normal behavior for this module? What am I missing?
--
David Bear
-- let me buy your intellectual property, I want to own your thoughts --
Jun 22 '06 #1
1 1107
In article <3026518.PBSJIyfHH0@teancum>,
David Bear <da********@asu.edu> wrote:
I'm using popen2 and getting an extra 1 at the end of my output. I didn't
see where this was explained in the docs so I clearly don't understand the
behavior. My code is simple.

(input, output) = os.popen2('whackyperlprogram')
results = output.read()
rc = output.close()
print results


What if, for comparison, you try running a trivial program that produces
no output:

(input, output) = os.popen2('/bin/true')
results = output.read()
rc = output.close()
print results

Do you still get the "1" at the end?
Jun 26 '06 #2

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

Similar topics

2
by: Tiziano Bettio | last post by:
Hi Everybody, I'm stuck trying to write a python module for the vlc videoplayer on linux (http://www.videolan.org). I'm using the popen2 module to open a pipe to the program. If I open the vlc...
1
by: | last post by:
This could possibly be a bug, but I don't understand it fully so I'm posting here first. Searching the list told me other people are having this problem too. I have created a class which...
1
by: Vivien Mallet | last post by:
Hello, I use popen2.Popen4 and I experienced problems with it. Let me show you with an example. The following script is called "lines" (it prints lines of 'X'): ---------------------...
2
by: Mage | last post by:
Hello, maybe my question is about linux and not about python. I tried to write a proxy script for "psql" command. I need some query log. I failed to read from the file object. I have...
1
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...
11
by: g.franzkowiak | last post by:
I start a process in my application with popen2.popen3('MyOtherProcess'). That's ok, but what can I do if the other process is running ? Can I fetch some information and start with that ? gerd
9
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 =...
3
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...
1
by: diego | last post by:
I'm trying to understand how popen2 works. Found in this group, that popen2.popen2 can cause trouble so i chose win32pipe.popen2. have a look a the listing of 2 files: ekmain.py: **************...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.