Bad file descriptor, but not on 2/3 computers....

T

Tag Ashby

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
 
R

Roger Pack

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
 
T

Tag Ashby

Roger said:
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.
 
R

Roger Pack

"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
 
T

Tag Ashby

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
 
R

Roger Pack

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/...ior-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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top