[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Help: expect.rb

stevarino

6/22/2006 3:59:00 PM

Ruby newbie, need help with expect.rb.

I am running:
ruby 1.8.4 (2005-12-24) [sparc-solaris2.7]
(downloaded from SunFreeware.com).

When I run:

ruby expect_sample.rb

it aborts with the following error message:

/usr/local/lib/ruby/1.8/expect.rb:17: `undefined method `chr' for
nil:NilClass' (NoMethodError)

Looking at expect.rb, the relevant code is:

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

Questions:

- It appears to me that getc is returning 'nil', which doesn't support
the 'chr' method.
but shouldn't the 'select().nil?' test prevent this?

- I assume expect.rb does not throw this error for everybody else --
any suggestions?

TIA,

Steve

12 Answers

Daniel Seix

6/23/2006 6:38:00 AM

0

stevarino wrote:

> When I run:
>
> ruby expect_sample.rb
>
> it aborts with the following error message:
>
> /usr/local/lib/ruby/1.8/expect.rb:17: `undefined method `chr' for
> nil:NilClass' (NoMethodError)
>

> - I assume expect.rb does not throw this error for everybody else --
> any suggestions?
>
> TIA,
>
> Steve

So what's this expect_sample.rb?

Dumaiu

6/23/2006 3:44:00 PM

0

I'll be! You may have discovered a bug. The error you reported
appears when you call expect() on a File and the stream is exhausted
without a match. IO::select() (which I had never seen before) doesn't
check for an EOF char, so you need something like

if IO.select( [self], nil, nil, timeout ).nil? or eof?

But expect.rb probably isn't the best thing to use for a project of
any significant complexity. There's a thread somewhere on c.l.r. where
Matz posted his "real" version of expect()--you might look for
that--and there's a project on RubyForge called 'RExpect' which also
functions in a more advanced capacity.

Welcome to the newsgroup, by the way.

stevarino

6/23/2006 3:57:00 PM

0

expect_sample.rb is a program that uses the expect.rb library.

It's in the 1.8.4 distribution: ./ext/pty/expect_sample.rb


Daniel Seix wrote:
> stevarino wrote:
>
> > When I run:
> >
> > ruby expect_sample.rb
> >
> > it aborts with the following error message:
> >
> > /usr/local/lib/ruby/1.8/expect.rb:17: `undefined method `chr' for
> > nil:NilClass' (NoMethodError)
> >
>
> > - I assume expect.rb does not throw this error for everybody else --
> > any suggestions?
> >
> > TIA,
> >
> > Steve
>
> So what's this expect_sample.rb?

stevarino

6/23/2006 4:05:00 PM

0

Thanks for the encouragement. I'm really enjoying Ruby!

Actually, all I need to do is to ftp a file; I've since found the much
easier approach
using NET::Ftp.

But there are occasions when an expect capability is indespensible.
I'll look into RExpect.

Thanks again.

Steve



Dumaiu wrote:
> I'll be! You may have discovered a bug. The error you reported
> appears when you call expect() on a File and the stream is exhausted
> without a match. IO::select() (which I had never seen before) doesn't
> check for an EOF char, so you need something like
>
> if IO.select( [self], nil, nil, timeout ).nil? or eof?
>
> But expect.rb probably isn't the best thing to use for a project of
> any significant complexity. There's a thread somewhere on c.l.r. where
> Matz posted his "real" version of expect()--you might look for
> that--and there's a project on RubyForge called 'RExpect' which also
> functions in a more advanced capacity.
>
> Welcome to the newsgroup, by the way.

Heinrich

1/13/2010 7:57:00 PM

0


"TheZ" <TheZ@nospam.com> schreef in bericht
news:_1p3n.4822$Sk4.2118@newsfe10.iad...
>I only wrote it to see if the Moslems in their rush to help, would inform
>us that they had dispatched a few suicide bombers in training to help do
>away with the sick and wounded children.
> Of course we didn't expect help from nazi's, you hate Jews and blacks
> equally.
>
i donot like moroccans either

TheZ

1/13/2010 8:53:00 PM

0

Actually having been to Morocco, I found them accommodating, Muslim light,
and a relatively well-off society as a whole.
My interpreter who was educated in Denmark in languages spoke impeccable
English. Susi as I called him, was his nickname, (it means from the south)
was a Berber. Hussein being his real name, he had a twin Hassan.
Susi was taken as a child by the State, educated abroad, and returned as a
ward of the government. His brother Hassan was allowed to remain with his
parents
I was grateful to him for keeping the insidious "minders", the government
tried to sic on me, away and satisfied.
One evening we crossed into the desert (technically north Africa), and had
supper in his parents tent. Wonderful meal, and interpreted conversation,
without the fear of being overheard.

"Heinrich" <Heinrich@Ruhrgasnet.de> wrote in message
news:7r6mt4FskgU1@mid.individual.net...
>
> "TheZ" <TheZ@nospam.com> schreef in bericht
> news:_1p3n.4822$Sk4.2118@newsfe10.iad...
>>I only wrote it to see if the Moslems in their rush to help, would inform
>>us that they had dispatched a few suicide bombers in training to help do
>>away with the sick and wounded children.
>> Of course we didn't expect help from nazi's, you hate Jews and blacks
>> equally.
>>
> i donot like moroccans either


chatnoir

1/13/2010 10:57:00 PM

0

On Jan 13, 12:52 pm, "TheZ" <T...@nospam.com> wrote:
> Actually having been to Morocco, I found them accommodating, Muslim light,
> and a relatively well-off society as a whole.

They liked Israel's support for thier invasion of Western Sahara

> My interpreter who was educated in Denmark in languages spoke impeccable
> English. Susi as I called him, was his nickname, (it means from the south)
> was a Berber. Hussein being his real name, he had a twin Hassan.
> Susi was taken as a child by the State, educated abroad, and returned as a
> ward of the government. His brother Hassan was allowed to remain with his
> parents
> I was grateful to him for keeping the insidious "minders", the government
> tried to sic on me, away and  satisfied.
> One evening we crossed into the desert (technically north Africa), and had
> supper in his parents tent. Wonderful meal, and interpreted conversation,
> without the fear of being overheard.
>
> "Heinrich" <Heinr...@Ruhrgasnet.de> wrote in message
>
> news:7r6mt4FskgU1@mid.individual.net...
>
>
>
>
>
> > "TheZ" <T...@nospam.com> schreef in bericht
> >news:_1p3n.4822$Sk4.2118@newsfe10.iad...
> >>I only wrote it to see if the Moslems in their rush to help, would inform
> >>us that they had dispatched a few suicide bombers in training to help do
> >>away with the sick and wounded children.
> >> Of course we didn't expect help from nazi's, you hate Jews and blacks
> >> equally.
>
> > i donot like moroccans either- Hide quoted text -
>
> - Show quoted text -

Heinrich

1/14/2010 5:01:00 AM

0


"TheZ" <TheZ@nospam.com> schreef in bericht
news:ooq3n.5295$5m.3023@newsfe12.iad...
> Actually having been to Morocco, I found them accommodating, Muslim light,
> and a relatively well-off society as a whole.
> My interpreter who was educated in Denmark in languages spoke impeccable
> English. Susi as I called him, was his nickname, (it means from the south)
> was a Berber. Hussein being his real name, he had a twin Hassan.
> Susi was taken as a child by the State, educated abroad, and returned as a
> ward of the government. His brother Hassan was allowed to remain with his
> parents
> I was grateful to him for keeping the insidious "minders", the government
> tried to sic on me, away and satisfied.
> One evening we crossed into the desert (technically north Africa), and had
> supper in his parents tent. Wonderful meal, and interpreted conversation,
> without the fear of being overheard.
>
thern you may praise yourself lucky. the moroccans we have goot hear are
from the rif mountain aerea and are good for nothing.they refuse to
integrateand to learn to speak the language as a result of which they are
ruining our social security system. they are really a pain in the arse and
cause a lot of trouble

TheZ

1/14/2010 5:24:00 AM

0

They were exemplary fighters against Spain and France in the 1920's. It has
since become a very poor area. The early Rif Berbers, once a proud group as
tribal traditionalists. The tribal laws took precedence over religious ones.
Although Muslims , they weren't considered so in the early 1900's.
Later as Islam overcame their tribalism traditions, they became despondent
and useless like most Muslims who have their lives ruled by the Quran.
With intermarriage to Arabs and loss of self respect through Islam many have
slipped into disarray, no longer being able to maintain their former
stature.
Failure to integrate is a Muslim trait not a Berber one, and being on
welfare is also a Muslim trait. Holland, Denmark, Sweden, Germany and
England will heartily attest to this.

"Heinrich" <Heinrich@Ruhrgasnet.de> wrote in message
news:7r7mp6F733U1@mid.individual.net...
>
> "TheZ" <TheZ@nospam.com> schreef in bericht
> news:ooq3n.5295$5m.3023@newsfe12.iad...
>> Actually having been to Morocco, I found them accommodating, Muslim
>> light, and a relatively well-off society as a whole.
>> My interpreter who was educated in Denmark in languages spoke impeccable
>> English. Susi as I called him, was his nickname, (it means from the
>> south) was a Berber. Hussein being his real name, he had a twin Hassan.
>> Susi was taken as a child by the State, educated abroad, and returned as
>> a ward of the government. His brother Hassan was allowed to remain with
>> his parents
>> I was grateful to him for keeping the insidious "minders", the government
>> tried to sic on me, away and satisfied.
>> One evening we crossed into the desert (technically north Africa), and
>> had supper in his parents tent. Wonderful meal, and interpreted
>> conversation, without the fear of being overheard.
>>
> thern you may praise yourself lucky. the moroccans we have goot hear are
> from the rif mountain aerea and are good for nothing.they refuse to
> integrateand to learn to speak the language as a result of which they are
> ruining our social security system. they are really a pain in the arse
> and cause a lot of trouble


Goyko Mitich

1/14/2010 9:11:00 AM

0

On Jan 14, 6:57 am, "Heinrich" <Heinr...@Ruhrgasnet.de> wrote:
> "TheZ" <T...@nospam.com> schreef in berichtnews:_1p3n.4822$Sk4.2118@newsfe10.iad...>I only wrote it to see if the Moslems in their rush to help, would inform
> >us that they had dispatched a few suicide bombers in training to help do
> >away with the sick and wounded children.
> > Of course we didn't expect help from nazi's, you hate Jews and blacks
> > equally.
>
> i donot like moroccans either

Morocco is the ancient motherland of the jews.
The shephardim who are 10 % of the jews are
the real deal!