From: Peter Vanderhaden Date: 2007-09-30T23:06:32+09:00 Subject: Re: Newbie needs help getting user input Sebastian, FYI, the reason I'm sending the prompt to STDERR instead of STDOUT is that I've used reopen to redirect STDOUT to a file. I did that because I want to write data to a file. I'm new to this, so if there's a better way to write to the file, I'm all ears :) PETERV Peter Vanderhaden wrote: > Sebastian, > My Ruby installation must be corrupt, as it doesn't recognize gets. > When I try your solution, I get the following error message: > > D:/scripts/ruby/f0.rb:10:in `gets': Bad file descriptor (Errno::EBADF) > from D:/scripts/ruby/f0.rb:10 > > I'd assume the best way to correct this would be to reinstall Ruby? > Would you agree? > > Thanks, > PETERV > > > Sebastian Hungerecker wrote: > >> Peter Vanderhaden wrote: >>> print STDERR "Enter option: "; >> >> The ruby equivalent of this would be STDERR.print "Enter option: " but >> why >> STDERR? That hardly looks like an error message to me. >> >>> chomp ($option = ); >> >> That would be gets.chomp or STDIN.gets.chomp if you want to make >> sure that >> you read from STDIN. >> >>> I've searched the web and several books, but I haven't found anything >>> that works. It also seems that my system doesn't recognize "gets". >> >> Your system is not supposed to recognize gets. If your ruby does not >> recognize >> gets, there is something seriously wrong with your ruby installation. >> >> >> HTH, >> Sebastian -- Posted via http://www.ruby-forum.com/.