[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

odd error with expect

Amos

2/15/2007 7:54:00 PM

I've had a trivial expect script in use for a while now, but with
1.8.5-p2 it no longer functions. In fact, the example expect script
doesn't work either. Both produce the same exception:

$ /usr/local/bin/ruby expect_sample.rb
/usr/local/lib/ruby/1.8/expect.rb:17:in `expect': undefined method
`chr' for nil:NilClass (NoMethodError)
from expect_sample.rb:18
from expect_sample.rb:13:in `spawn'
from expect_sample.rb:13

The only 'chr' I see is the following in expect.rb:

while true
if IO.select([self],nil,nil,timeout).nil? then
result = nil
break
end
c = getc.chr
buf << c

Suggestions?

2 Answers

John Tajima

2/26/2007 3:19:00 PM

0

Amos wrote:
> I've had a trivial expect script in use for a while now, but with
> 1.8.5-p2 it no longer functions. In fact, the example expect script
> doesn't work either. Both produce the same exception:
>
> $ /usr/local/bin/ruby expect_sample.rb
> /usr/local/lib/ruby/1.8/expect.rb:17:in `expect': undefined method
> `chr' for nil:NilClass (NoMethodError)
> from expect_sample.rb:18
> from expect_sample.rb:13:in `spawn'
> from expect_sample.rb:13
>
> The only 'chr' I see is the following in expect.rb:
>
> while true
> if IO.select([self],nil,nil,timeout).nil? then
> result = nil
> break
> end
> c = getc.chr
> buf << c
>
> Suggestions?

Hi,
I came up with the same problem, except mine was running 1.8.4 on
Solaris - but was working running on linux.

If someone has suggestions, please let us know.


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

Brian Candler

2/27/2007 9:32:00 AM

0

On Tue, Feb 27, 2007 at 12:18:40AM +0900, John Tajima wrote:
> Amos wrote:
> > I've had a trivial expect script in use for a while now, but with
> > 1.8.5-p2 it no longer functions. In fact, the example expect script
> > doesn't work either. Both produce the same exception:
> >
> > $ /usr/local/bin/ruby expect_sample.rb
> > /usr/local/lib/ruby/1.8/expect.rb:17:in `expect': undefined method
> > `chr' for nil:NilClass (NoMethodError)
> > from expect_sample.rb:18
> > from expect_sample.rb:13:in `spawn'
> > from expect_sample.rb:13
> >
> > The only 'chr' I see is the following in expect.rb:
> >
> > while true
> > if IO.select([self],nil,nil,timeout).nil? then
> > result = nil
> > break
> > end
> > c = getc.chr
> > buf << c
> >
> > Suggestions?
>
> Hi,
> I came up with the same problem, except mine was running 1.8.4 on
> Solaris - but was working running on linux.
>
> If someone has suggestions, please let us know.

Well, it looks like getc is returning nil. But this is despite the fact that
IO.select has said that there is data available to read.

Maybe you have discovered a problem with IO.select. Can you share your
script which demonstrates the problem? What is the "example expect script"
you are referring to? I don't see one on my system.

$ find /usr/share/doc/ruby-1.8.5/sample -type f | xargs grep expect
$

Or maybe the behaviour of IO.select has changed in an incompatible way, e.g.
on an EOF condition.

Otherwise, there might be some sort of race condition (e.g. IO.select says
the descriptor is ready but by the time you read from it, the other end has
closed the connection).

As a simple workaround, you could try replacing the line "c = getc.chr"
with:

c = getc
if c.nil?
result = nil
break
end
c = c.chr

Regards,

Brian.