From: <ex...@ih...> - 2002-07-23 15:14:40
|
On Tue, 23 Jul 2002 11:05:21 +0200 Roland Giersig <RGi...@cp...> wrote: > > Ok, I know it's not healthy to talk to myself.... ;^) > > Well, it's a start... :-) > > > The problem seems to be some difference in how regex is handled. > > > > If I just do $obj->expect(undef, $item); > > everything works fine. > > > > If I use instead $obj->expect(undef, -re => "$item"); > > Things fail mysteriously (to me anyway). I'm certain that my > > understanding > > of this module is incomplete so it's possible that I'm missing the > > distinction between these 2 idioms. > > perldoc Expect: > > Changed from older versions is the regular expression > handling. By default now all strings passed to expect() > are treated as literals. To match a regular expression > pass '-re' as a parameter in front of the pattern you > want to match as a regexp. > > Example: > > $object->expect(15, 'match me exactly','-re','match\s+me\s+exactly'); > > Anything unclear with that? Should the docs be worded differently? > > > > > The spawned program is an sh script. The timeout comes only after > > > > a few seconds at one point when the script is doing work. > > > > Why is it timing out? Is something strange happening to > > > > $end_time? > > > > > > > > Here's the bit of code from Expect.pm that gets me > > > > to this point: > > > > > > > > 1329: if (($end_time <= time()) && ${*$self}{exp_Debug}) { > > > > 1330: print STDERR "Timed out waiting for an EOF from > > ${*$self}{exp_Pty_Handle}.\r\n"; > > > > 1331: } > > > > > > > > Can anyone provide any clues? > > Without you providing more code? No. Don't think we're on the same wavelength, I suspect that it's my fault for not providing enough info. I do understand "-re", I do not understand why "-re" fails and when I don't specify "-re" things are fine. In my previous post I noted that I was seeing this which I only saw when I used $obj->expect(undef, -re => "$item"); and this showed up Use of uninitialized value in concatenation (.) or string at /usr/btools/perl/lib/site_perl/5.6.1/Expect.pm line 1388 If I use this I have no problems: $obj->expect(undef, $item); So what's different about the code path for those two that causes one to fail? Essentially that's all the code there is, it waits for a string which is a "key" value and provides the corresponding "value" value. It almost appears as if the -re idiom is not respecting the undef for the timeout value and therefore is not waiting indefinitely. |