Now I want to use it whith pipes like this:
dir | count
but i got this error
C:\ruby>dir | count
C:/ruby/count.rb:3:in `each_line’: Bad file descriptor (Errno::EBADF)
from Z:/ruby/count.rb:3
What is the problem?
(NB: I an working on Windows2000.)
Now I want to use it whith pipes like this:
dir | count
but i got this error
C:\ruby>dir | count
C:/ruby/count.rb:3:in `each_line’: Bad file descriptor (Errno::EBADF)
from Z:/ruby/count.rb:3
What is the problem?
(NB: I an working on Windows2000.)
I guess that’s the problem. AFAIK there are some troubles with Windows
pipes…
At Thu, 18 Dec 2003 19:57:08 +0900, Jean-Baptiste wrote:
Now I want to use it whith pipes like this:
dir | count
but i got this error
C:\ruby>dir | count
C:/ruby/count.rb:3:in `each_line’: Bad file descriptor (Errno::EBADF)
from Z:/ruby/count.rb:3
What is the problem?
(NB: I an working on Windows2000.)
Perl distributes a little script called pl2bat which appends a batch
file header to the script so that it can be run as a batch file, which
fixes this problem. The same works for ruby; below is your script with a
batch header. name the file with a .bat extension and it should work fine.
-----><8----- @rem = '–-Ruby-– @echo off
if “%OS%” == “Windows_NT” goto WinNT
ruby -x -S “%0” %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
ruby -x -S %0 %*
if NOT “%COMSPEC%” == “%SystemRoot%\system32\cmd.exe” goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofruby @rem ';
#!ruby #line 15
Now I want to use it whith pipes like this:
dir | count
but i got this error
C:\ruby>dir | count
C:/ruby/count.rb:3:in `each_line’: Bad file descriptor (Errno::EBADF)
from Z:/ruby/count.rb:3
What is the problem?
(NB: I an working on Windows2000.)
Now I want to use it whith pipes like this:
dir | count
but i got this error
C:\ruby>dir | count
C:/ruby/count.rb:3:in `each_line’: Bad file descriptor (Errno::EBADF)
from Z:/ruby/count.rb:3
What is the problem?
(NB: I an working on Windows2000.)
I guess that’s the problem. AFAIK there are some troubles with Windows
pipes…
robert
I get the same error for:
c:> dir | count
but it appears to work as you’d expect for:
c:> dir | ruby count.rb
Hmm, that’s strange. if run as ‘count.bat <somefile’ or ‘cat
somefile>count.bat’ it works, but I get a similar error ‘ruby: No Ruby
script found in input (LoadError)’ when run as you did. I haven’t seen
this behavior before, and don’t know a way around it except to use the
forms I showed that do work.