Forum: Ruby Open.popen3(cmd) generates always Error::PIPE .....

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7caba80fca2ac4ddbb7f55957e5c0dec?d=identicon&s=25 Jun Young Kim (Guest)
on 2008-12-10 09:51
(Received via mailing list)
Hi,

The below example code shows all thing I have.

cmd = 'my_command options'

begin
  Open.popen3(cmd) do | stdin, stdout, stderr|
    while line = stdout.gets
      $stdout.write(line)
    end
  end
rescue => e
  STDERR.puts(e)
end

When I execute cmd string in shell, it will be run another ruby
program based on Ruby.Tk.

Anyway, finally, I got alway same error

"Broken Pipe"

;-<  I  don't understand why this thing was happened.

This is a workaround solution to run this program properly.


cmd = 'my_command options'

begin
  Open.popen3(cmd) do | stdin, stdout, stderr|
    while line = stdout.gets
      $stderr.write(line)
    end
  end
rescue => e
  STDERR.puts(e)
end


When I execute this one, the program is running normally.

Are there nice way I can take ? I dont want use $stderr to just print
out my output ....
This topic is locked and can not be replied to.