Grokbase Groups Python tutor May 2005
FAQ

At 11:56 AM 5/12/2005, Danny Yoo wrote:
* * * *
CLAMAV_out, CLAMAV_in, CLAMAV_err= popen2.popen3(CLAMAV)
CLAMAV_in.write(WORKING)
CLAMAV_in.close()
CLAM_RESULT=CLAMAV_out.read()
CLAMAV_out.close()
CLAM_ERR=CLAMAV_err.read()
CLAMAV_err.close()
* * * *

CLAM_RESULT gives the correct reply, and stderr is 1. But CLAM_ERR is
empty. This seems like it should be simple -- what am I missing?
I think I am messing this up! What I actually need is the exitcode of the
spawned command, which is why stderr did not contain the info I wanted. It
seems there is a new problem: to get the exitcode of the spawned process,
not the "shell" that contains it. I found this example on another list
that seems to address this problem:

http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/68786
As a work around, I end up calling popen3 like this:

Open3.popen3 ("/some/command/to/run ; echo $? 1>&2") { ... }

That ensures the exit code from /some/command/to/run will be the last
line of the standard error stream from Open3.popen3. Then I can just
pull that line off the output to get the return code.


Is there a more elegant way to get the exitcode off the child process, or
is this the "approved" method?

Jeff

* * * * * * *
Jeffrey Rice || jeffrice at finity.org || www.finity.org

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 5 | next ›
Discussion Overview
grouptutor @
categoriespython
postedMay 12, '05 at 5:56p
activeMay 12, '05 at 11:10p
posts5
users2
websitepython.org

2 users in discussion

Danny Yoo: 3 posts Jeffrey Rice: 2 posts

People

Translate

site design / logo © 2022 Grokbase