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

I am attempting to loop a waitfor statement like so:
until ($t->waitfor('/REPORT FINISHED/') == 1) { ($op1) = $t->waitfor('/PRESS RETURN/'); print NVFILE $op1; $t->print(""); }
This should capture each screen of the report to a file and press ENTER until it sees 'REPORT FINISHED'. I suspect I may not be evaluating this correctly. Thanks

Replies are listed 'Best First'.
Re: Net::Telnet waitfor loop
by ssandv (Hermit) on Aug 17, 2009 at 22:17 UTC
    It would be nice if you told us what you're getting in NVFILE. (Obligatory suggestions to use strict, warnings, and 3-argument open here). Offhand, two things I could suggest are that you might be running afoul of the timeout (which is set by default in Net::Telnet) or that you aren't for whatever reason, matching. Have you used dump_log() to see what's coming through?
      Sorry for the delay in updating. To many 'must be done now' issues. Currently I am getting nothing in the NVFILE (zero byte file). If I wasn't trying to loop, I can get the first page of the on-screen report. I am using strict & warnings - I will check on the three arg open. I have not yet used the dump log feature on this. I also suspect that it is timing out.
        Dump_log and Input_log both show that I am getting the first page of the on-screen report. It indeed IS dying on the until line. Here is the updated code:
        until ($t->waitfor('/REPORT FINISHED/') == 1) { ($op1) = $t->waitfor('/PAGE/'); print NVFILE $op1; ($op2) = waitfor('/PRESS RETURN/'); print NVFILE $op2; $t->print(""); }
        Thanks!