gnangia has asked for the wisdom of the Perl Monks concerning the following question:

I am using Expect.pm verison 1.15 (latest release) to automate a login process. Everything works fine but I was working on the error handling routine and wanted to find out how to catch the "received" sting(s) single or multiline - i.e. while "expecting" a result, if no match, I want to print what was actually received versus what was expected. I have used the function exp_error() but that only gives 1:TIMEOUT, which really does not give me any information because this will always be true when the expected string does not match the received string.
Please advise.

Replies are listed 'Best First'.
(jeffa) Re: Using perl module Expect.pm
by jeffa (Bishop) on Dec 11, 2002 at 16:48 UTC
    I think you can use before() to accomplish this. From the docs:
       $object->before()
           before() returns the 'before' part of the last
           expect() call. If the last expect() call didn't match
           anything, exp_before() will return the entire output
           of the object accumulated before the expect() call
           finished.
    
    And further down in Q&A:
       Ok, so now how do I get what was read on the handle?
    
         $read = $process->before();
    

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Hi jeffa,
      I have already looked at that and it is returning the received string + what I sent rather than just the string that it receives. So I then need to modify the contents of $object->before(). I was hoping to just to get what was received rather than sent+received. I also inserted a $object->clear_accum() thinking that it would clear the buffer of what was sent. However, it did not make a difference.