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.
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.
Hi Jeffrey,
Ah! Ok, you're looking for the error code too.
Is there a more elegant way to get the exitcode off the child process,
or is this the "approved" method?
Yeah; check the Popen3 object in the 'popen2' module: it has a separateor is this the "approved" method?
way of getting at the error code:
http://www.python.org/doc/lib/popen3-objects.html
For example:
######
import popen2
process = popen2.Popen3(['wc'])
process.tochild.write("hello\nworld")
process.tochild.close()
process.fromchild.read()
process = popen2.Popen3(['wc'])
process.tochild.write("hello\nworld")
process.tochild.close()
process.fromchild.read()
process.fromchild.close()
process.wait()
process.wait()
Hope this helps!