Novice Question: Getting "bad file descriptor error" when trying to use gets in ruby 1.8.1 for windows


#1

Hi I’m trying to run this code:
while (line = gets)
puts “The given line is #{line}”
if line =~ /^eval:(.*)$/
puts “#$1 # => #{eval $1}”
end
end

That I found on a tutorial website. Ruby gives me this error when I try to run it:

ruby guessnumber.rb
higuessnumber.rb:4:in `gets’: Bad file descriptor (Errno::EBADF)
from guessnumber.rb:4
Exit code: 1

Why is this happening?


(Zach Dennis) #2

This codes run mighty fine on my win2k, 1.8.1 build. Does the error occur
when you run the script period or when you type something in after the
script is run? Also, what build and on what system are you running this on?

Zach

···

-----Original Message-----
From: Revision17 [mailto:revision17@phreaker.net]
Sent: Thursday, February 12, 2004 11:30 PM
To: ruby-talk ML
Subject: Novice Question: Getting “bad file descriptor error” when
trying to use gets in ruby 1.8.1 for windows

Hi I’m trying to run this code:
while (line = gets)
puts "The given line is #{line}"
if line =~ /^eval:(.*)$/
puts "#$1 # => #{eval $1}"
end
end

That I found on a tutorial website. Ruby gives me this error when I try to
run it:

ruby guessnumber.rb
higuessnumber.rb:4:in `gets’: Bad file descriptor (Errno::EBADF)
from guessnumber.rb:4
Exit code: 1

Why is this happening?


Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004


(Shashank Date) #3

“Revision17” revision17@phreaker.net wrote in message

That I found on a tutorial website. Ruby gives me this error when I try
to run it:

ruby guessnumber.rb
higuessnumber.rb:4:in `gets’: Bad file descriptor (Errno::EBADF)
from guessnumber.rb:4
Exit code: 1

Why is this happening?

Are you running this through an Editor (may be SciTE or TextPad?)
IF that is the case then try it from the command prompt.

– shanko


#4

“Shashank Date” sdate@everestkc.net wrote in message news:c0io9h$18bh89$1@ID-194283.news.uni-berlin.de

“Revision17” revision17@phreaker.net wrote in message

That I found on a tutorial website. Ruby gives me this error when I try
to run it:

ruby guessnumber.rb
higuessnumber.rb:4:in `gets’: Bad file descriptor (Errno::EBADF)
from guessnumber.rb:4
Exit code: 1

Why is this happening?

Are you running this through an Editor (may be SciTE or TextPad?)
IF that is the case then try it from the command prompt.

– shanko

Yes I am (SciTE). I’ll try it out without when I get back to my
computer on Sunday. Is there any way to get it to work with SciTE
though? It’s so convenient to just hit f5 and you can see the
program’s output.


(daz) #5

“Revision17” wrote:

“Shashank Date” wrote:

Are you running this through an Editor (may be SciTE or TextPad?)
IF that is the case then try it from the command prompt.

– shanko

Yes I am (SciTE). I’ll try it out without when I get back to my
computer on Sunday. Is there any way to get it to work with SciTE
though?

This problem was fixed in later versions of SciTE.

There’s a good one-click installer (v 1.57 unless you want
Lua scripting support) here:

http://gisdeveloper.tripod.com/scite.html

Make sure you won’t overwrite your customised properties files.
You may need to refer to the way things were, later.

It’s so convenient to just hit f5 and you can see the
program’s output.

Indeed it is.

Which is one reason I use RDE:
http://homepage2.nifty.com/sakazuki/rde_e.html
(not as straightforward to install, but it does a whole fat lot more)

daz


(Shashank Date) #6

“Revision17” revision17@phreaker.net wrote in message

Is there any way to get it to work with SciTE
though?

Yes, there is :

http://rubygarden.com/ruby?SciTEAndStdinStdout

Works for me on Windows XP (Home Edition).

– shanko