Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > popen2 question

Reply
Thread Tools

popen2 question

 
 
David Bear
Guest
Posts: n/a
 
      06-22-2006
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 --
 
Reply With Quote
 
 
 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      06-26-2006
In article <3026518.PBSJIyfHH0@teancum>,
David Bear <(E-Mail Removed)> 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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
popen2.Popen3 process destruction Python 1 06-15-2004 10:35 PM
Possible problem with popen2 module A. Lloyd Flanagan Python 2 05-03-2004 02:17 PM
popen2 trouble Diez B. Roggisch Python 2 04-05-2004 12:05 PM
popen2 with large input cherico Python 2 01-29-2004 02:14 PM
popen2 Guy Python 1 08-12-2003 04:57 PM



Advertisments