Professional Web Applications Themes

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

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:  higuessnumber.rb:4:in `gets': Bad file descriptor (Errno::EBADF) from guessnumber.rb:4  Why is this happening?...

  1. #1

    Default 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: 
    higuessnumber.rb:4:in `gets': Bad file descriptor (Errno::EBADF)
    from guessnumber.rb:4 

    Why is this happening?
    Revision17 Guest

  2. #2

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


    "Revision17" <net> wrote in message 
    to run it: 
    > higuessnumber.rb:4:in `gets': Bad file descriptor (Errno::EBADF)
    > from guessnumber.rb:4 
    >
    > Why is this happening?[/ref]

    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


    Shashank Guest

  3. #3

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

    "Shashank Date" <net> wrote in message news:<c0io9h$18bh89$news.uni-berlin.de>... 
    > to run it: 
    > > higuessnumber.rb:4:in `gets': Bad file descriptor (Errno::EBADF)
    > > from guessnumber.rb:4 
    > >
    > > Why is this happening?[/ref]
    >
    > 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[/ref]

    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.
    Revision17 Guest

  4. #4

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

     
    >
    > 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?[/ref]


    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.

     

    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



    daz Guest

  5. #5

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


    "Revision17" <net> wrote in message 

    Yes, there is :

    http://rubygarden.com/ruby?SciTEAndStdinStdout

    Works for me on Windows XP (Home Edition).

    -- shanko


    Shashank Guest

Similar Threads

  1. Replies: 3
    Last Post: April 26th, 06:07 AM
  2. why "Bad file descriptor at line 94 "
    By Mark123 in forum PERL Beginners
    Replies: 2
    Last Post: January 29th, 02:53 PM
  3. Replies: 3
    Last Post: September 4th, 04:05 PM
  4. #9567 [Com]: Warning: file("http://www.php.net") - Bad file descriptor in /usr/........
    By bojan dot kraut at birostroj dot com in forum PHP Development
    Replies: 0
    Last Post: August 5th, 03:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139