From: Rui M. <rme...@te...> - 2007-05-09 11:23:59
|
Thanks for the advices given, but I managed to solve my problem! =20 I was doing everything right, and the way you told me. The problem was my prompt, in those LONG OUTPUT commands I gave (show running-config) there were certain characters that caused this regex to match: =20 my $prompt_default =3D "[\\\$%#>]\\s*(\\(enable\\)|)\\s*"; # A = strange prompt, but it=92s working fine (NO, IT WASN=92T !!!) (=85) qr/$prompt_default/, (=85) =20 I had this: $stdout =3D $exp->before() . $exp->match() . $exp->after(); match() was matching much earlier than I expected, and after() was the = one that was being truncated!!! =20 After some headaching troubleshooting, I found out that I simply needed = to change this line to make the match work where I intended it to work (at = the end): =20 qr/\n\S+$prompt_default$/, =20 =20 Now everything works fine! Thanks a lot. =20 =20 =20 _____ =20 From: exp...@li... [mailto:exp...@li...] On Behalf Of li...@jo... Sent: ter=E7a-feira, 8 de Maio de 2007 23:25 To: exp...@li... Subject: Re: [Expectperl-discuss] Output from before() gets truncated if = Re: Output from before() gets truncated if it's too long =20 Here's something that worked for me... 1. Expect on the system prompt ( qr/^REQ: / in my case) then send the command to print the listing 2. Optionally "expect" the command (to absorb it from the listing), you = can also absorb any headers you don't want.=20 3. Now let the system do its work. 4. Expect on another system prompt. Whatever printed in step 3 (i.e. from the system) is stored in $exp->before(), this is your listing. =20 Example: # Step 1: Get the system prompt and send a response... $exp->expect(10, [ qr/^REQ: / =3D> sub { $self =3D shift; $self->send("PRINT\r") } ], [ timeout =3D> sub { die ("Timeout in step 1") } ] ); # Step 2 not coded # Step 3: System prints stuff here # Step 4: Find the next system prompt $exp->expect(10, [ qr/^REQ: / ], [ timeout =3D> sub { die ("Timeout in step 4") } ] ); $listing =3D $exp->before(); print $listing; Regards, John. =20 =20 =20 |