# Open.popen3(cmd) generates always Error::PIPE

**URL:** <https://www.ruby-forum.com/t/open-popen3-cmd-generates-always-error-pipe/155291>\
**Category:** Ruby\
**Created:** [December 10, 2008, 9:51am UTC](https://www.ruby-forum.com/t/open-popen3-cmd-generates-always-error-pipe/155291 "2008-12-10T09:51:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jun\_YSKim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@Jun\_YSKim](https://www.ruby-forum.com/u/Jun_YSKim)\
**Post date:** [December 10, 2008, 9:51am UTC](https://www.ruby-forum.com/t/open-popen3-cmd-generates-always-error-pipe/155291/1 "2008-12-10T09:51:41Z")

</div>

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 …
