C
Clayton Wozney
I'm using Ruby to create little command line utilities that read from
STDIN and write to STDOUT so that I can string them together with pipes.
The I/O part looks like this...
# open up STDIN for reading
infile = IO.new(0, "r")
# read from STDIN until EOF
infile.each_line do |line|
Now, this works fine when I run it from the command line directly (no
pipe). However, when I try to use a pipe like this (for example):
c:\>type file.txt | ruby_script.rb
I get this error message:
The process tried to write to a nonexistent pipe.
ruby_script.rb:23:in `each_line': Bad file descriptor (Errno::EBADF)
from ruby_script.rb:23
Is there another way to achieve this effect? Thanx.
Clayton.
STDIN and write to STDOUT so that I can string them together with pipes.
The I/O part looks like this...
# open up STDIN for reading
infile = IO.new(0, "r")
# read from STDIN until EOF
infile.each_line do |line|
Now, this works fine when I run it from the command line directly (no
pipe). However, when I try to use a pipe like this (for example):
c:\>type file.txt | ruby_script.rb
I get this error message:
The process tried to write to a nonexistent pipe.
ruby_script.rb:23:in `each_line': Bad file descriptor (Errno::EBADF)
from ruby_script.rb:23
Is there another way to achieve this effect? Thanx.
Clayton.