Pawel Radecki wrote: > Hello everybody! > > I'm trying to write a simple program that reads text from standard input > and writes text to standard output. The source code is as follows: > > #!/usr/bin/env ruby > text = "" > while (line = gets) > text+=line > end > print text.reverse > > > Now I want to execute it on the Windows XP box with a pipe to redirect > results so I know that: > > reverse.rb sample.txt | reverse.rb > > will show me (on the screen be default) the contents of sample.txt file > in non-reversed way. > I'm executing above command line and getting this: > > reverse.rb:9:in 'gets': Bad file descriptor (Errno:EBADF) > > > Do you have any ideas why it doesn't work? > > Thanks in advance for any help! When I get that error, it usually means that I am trying to read(e.g. gets) from something that is opened for writing only. I'm not sure how knowing that is useful in this case. Isn't the command: reverse.rb sample.txt | reverse.rb equivalent to: cat sample.txt ?? -- Posted via http://www.ruby-forum.com/.