From: John S. <j.d...@re...> - 2000-11-24 18:26:06
|
On Wed, 22 Nov 2000, Roland Giersig wrote: > Expect v1.09 has been uploaded to CPAN and > Sourceforge (http://sourceforge.net/projects/expectperl/). > > This is a bugfix release: exp_before didn't get set on timeout, OK, I now get something from exp_before after a timeout, but I still don't think the module's working correctly (or maybe I'm missing something) If I do: #!/usr/bin/perl -w use strict; use Expect; print "Expect version ", Expect::version, "\n"; my $EXPECT_OBJECT = Expect->spawn("telnet somehost"); $Expect::Exp_Internal = 1 ; my ($pos, $err, $match, $before, $after) = $EXPECT_OBJECT->expect(9, 'this_will_never_match') ; print STDERR "pos\t[$pos]\nerr\t[$err]\nbefore\t[$before]\nmatch\t[$match]\nafter\t[$after]\n"; print STDERR ("exp_before:\t[", $EXPECT_OBJECT->exp_before(), "]\n") ; - then (see after .sig) I get undefined values from expect, but I do get everything expect received up until the timeout with the exp_before() call. Accordiong to the docs: If called in an array context expect() will return ($matched_pattern_position, $error, $successfully_matching_string, $before_match, and $after_match). ... $error is the error that occurred that caused expect() to return. $error will contain a number followed by a string equivalent expressing the nature of the error. Possible values are undef, indicating no error, '1:TIMEOUT' indicating that $timeout seconds had elapsed without a match, .... I'm not getting the '1:TIMEOUT' string. I would also have exoected to get the same returned from expect() in $before as I get calling exp_before(). regards, -- John Stumbles j.d...@re... I.T. Services Centre, University of Reading http://www.rdg.ac.uk/~visstmbl +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Expect version 1.10 ... Use of uninitialized value at extest.pl line {first print line} Use of uninitialized value at extest.pl line ... Use of uninitialized value at extest.pl line ... ..etc.. pos [] err [] before [] match [] after [] exp_before: [Trying 123.45.6.7... Connected to somehost. Escape character is '^]'. SunOS 5.6 login: ] |