I am running a Ruby program that takes files from the command line and
then edits them based on user input. This part works perfectly fine.
The issue I am having is that when I pass an *input* file I am getting
an error:
"in 'gets': Bad file descriptor (Errno::EBADF)"
I have tested this program on three machines, a windows laptop, a mac
laptop, and a windows desktop.
The program runs perfectly on the two laptops, but not on my desktop.
The command line for the file looks like: Decrypt.rb test1.in test2.in
<input.in
I have no idea what that error is dealing with because the program runs
perfectly on the two laptops.
Thank you,
Tag
···
--
Posted via http://www.ruby-forum.com/.
The issue I am having is that when I pass an *input* file I am getting
an error:
"in 'gets': Bad file descriptor (Errno::EBADF)"
Could try other ruby versions.
-rp
···
--
Posted via http://www.ruby-forum.com/\.
"in 'gets': Bad file descriptor (Errno::EBADF)"
..
I have no idea what that error is dealing with because the program runs
perfectly on the two laptops.
I have seen something like this before, with 1.9...re-running the script
(perhaps after a few second pause) fixed it there, and I was never able
to come up with a reproducible test script to reproduce the problem. If
you can then forward it on.
-rp
···
--
Posted via http://www.ruby-forum.com/\.
The program runs perfectly on the two laptops, but not on my desktop.
The command line for the file looks like: Decrypt.rb test1.in test2.in
<input.in
That is indeed odd. You'd have to go down into the C to see why that is
happening (and try to reproduce it with "straight C" or what not).
Perhaps it is caused by a subtle difference in OS or msvcrt.dll version?
Anyway, you could work around by noting that gets "by default" reads
from the files passed as parameters:
http://stackoverflow.com/questions/2294439/unexpected-gets-behavior-with-commandline-arguments-in-ruby-closed
But I'd probably do something like
$ ruby Decrypt.rb test1.in test2.in input.in
file = File.open(ARGV.pop, 'r')
file.gets
GL.
-rp
···
--
Posted via http://www.ruby-forum.com/\.
Roger Pack wrote:
Could try other ruby versions.
-rp
Thank you Roger, I had forgot to mention that the program is part of a
class and the online grading system only takes the ruby version I am
using. (1.8.7)
All three computers use the same Ruby version.
···
--
Posted via http://www.ruby-forum.com/\.
I have seen something like this before, with 1.9...re-running the script
(perhaps after a few second pause) fixed it there, and I was never able
to come up with a reproducible test script to reproduce the problem. If
you can then forward it on.
-rp
To be honest I'm not precisely sure what you mean. This error occurs
every time I run the program.
It takes command-line arguments: Decrypt.rb test1.in test2.in < input.in
···
--
Posted via http://www.ruby-forum.com/\.