[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Bad file descriptor error

Mwenge Mulenga

4/11/2009 7:49:00 PM

Hello everyone,
I'm new to ruby.I'm trying to write an application that would
synchronise with google calendar.Below is a script I'm trying to use for
authentication with google.When I try to run it I'm getting a bad file
descriptor error.I have also provided the error message just after the
script.Any help will be appriciated.Thank you in advance.

def authentication(email,passwd,service)
require 'net/https'
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = '/accounts/ClientLogin'


# Now we are passing in our actual authentication data.
data = 'accountType=HOSTED_OR_GOOGLE&Email=email &Passwd=passwd
&service=service'

# Set up a hash for the headers
headers = { 'Content-Type' => 'application/x-www-form-urlencoded'}

# Post the request and print out the response to retrieve our
authentication token
resp, data = http.post(path, data, headers)

# Strip out our actual token (Auth) and store it
cl_string = data[/Auth=(.*)/, 1]

# Build our headers hash and add the authorization token
headers["Authorization"] = "GoogleLogin auth=#{cl_string}"
end



#After calling this function like this:
authentication("my_add@gmail.com","passwd","cl")

#I get the follow error message:


Errno::EBADF: Bad file descriptor
from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `write'
from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `warn'
from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `connect'
from C:/Ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
from C:/Ruby/lib/ruby/1.8/net/http.rb:542:in `start'
from C:/Ruby/lib/ruby/1.8/net/http.rb:1035:in `request'
from C:/Ruby/lib/ruby/1.8/net/http.rb:845:in `post'
from (irb):15:in `authentication'
from (irb):23
from :0
irb(main):024:0>
--
Posted via http://www.ruby-....

5 Answers

Roger Pack

4/12/2009 2:58:00 AM

0


> Errno::EBADF: Bad file descriptor
> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `write'
> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `warn'
> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `connect'
> from C:/Ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
> from C:/Ruby/lib/ruby/1.8/net/http.rb:542:in `start'
> from C:/Ruby/lib/ruby/1.8/net/http.rb:1035:in `request'
> from C:/Ruby/lib/ruby/1.8/net/http.rb:845:in `post'
> from (irb):15:in `authentication'
> from (irb):23
> from :0
> irb(main):024:0>

It may mean that google has summarily hung up on you.
-=r
--
Posted via http://www.ruby-....

Mwenge Mulenga

4/12/2009 3:17:00 AM

0

Roger Pack wrote:
>
>> Errno::EBADF: Bad file descriptor
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `write'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `warn'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `connect'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:542:in `start'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:1035:in `request'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:845:in `post'
>> from (irb):15:in `authentication'
>> from (irb):23
>> from :0
>> irb(main):024:0>
>
> It may mean that google has summarily hung up on you.
> -=r

Thank you Roger.Any suggestions on how I can fix this problem?Do I have
to changing some parameters or something in those lines?
--
Posted via http://www.ruby-....

Roger Pack

4/12/2009 3:33:00 AM

0


>> It may mean that google has summarily hung up on you.
>> -=r
>
> Thank you Roger.Any suggestions on how I can fix this problem?Do I have
> to changing some parameters or something in those lines?

very carefully check the parameters to make sure they're right is the
only thing I can imagine.

--
Posted via http://www.ruby-....

Mwenge Mulenga

4/12/2009 4:08:00 AM

0

Roger Pack wrote:
>
>>> It may mean that google has summarily hung up on you.
>>> -=r
>>
>> Thank you Roger.Any suggestions on how I can fix this problem?Do I have
>> to changing some parameters or something in those lines?
>
> very carefully check the parameters to make sure they're right is the
> only thing I can imagine.

I definately will.
--
Posted via http://www.ruby-....

Robert Klemme

4/12/2009 3:54:00 PM

0

On 12.04.2009 04:58, Roger Pack wrote:
>> Errno::EBADF: Bad file descriptor
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `write'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `warn'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `connect'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:542:in `start'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:1035:in `request'
>> from C:/Ruby/lib/ruby/1.8/net/http.rb:845:in `post'
>> from (irb):15:in `authentication'
>> from (irb):23
>> from :0
>> irb(main):024:0>
>
> It may mean that google has summarily hung up on you.

I believe you would see a different error. EBADF occurs, if the file
descriptor (i.e. the numeric value) is invalid. You can provoke it by
doing something like this

ruby -e 'File.open(10, "w") {|f| f.puts "test"}'

Whereas it does not happen if you do

ruby -e 'File.open(1, "w") {|f| f.puts "test"}'

One way to create this is to open a file, remember the number returned
from #fileno, close the file and then open another file with the
remembered number (file descriptor).

Kind regards

robert