Odd error with expect

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 methodchr’ 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?

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 methodchr’ 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.

On Tue, Feb 27, 2007 at 12:18:40AM +0900, John T. wrote:

    from expect_sample.rb:13

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs