From: Martin Kaletsch Date: 2005-01-12T22:21:17+09:00 Subject: Re: return code from Open3.popen? Daniel Berger wrote: >> Is there a (non-hackish) way to get the error code from > Open3.popen()? >> The only way I seem to be able to do it currently is by appending > "echo >> $?" to the command, and parsing it out of stdout. $?.exitstatus > contains >> some random value. > > The normal way of getting an error out of Open3.popen3 is to check the > STDERR handle: > > fin, fout, ferr = Open3.popen3("ls") > error = ferr.gets > if error > puts "Error: " + error.to_s # There was an error > end I know of at least one programm using stderr for output even when execution was successfull! -- Martin Kaletsch