in reply to Re: How to grab the telnet screen output?
in thread How to grab the telnet screen output?

Thanks:-)

I forgot to mention that I was using Net::Telnet module. Now the problem is kind of fixed, but some wired problem just remain :-(

I use get to get the content of sub menu, and remove the telnet control sequences, then have the clean and tidy text manipulated.

The problem is that I can not use getline, or getlines, they offer nothing to me. And I can not use waitfor because the last several lines of the control menu are all same, so...

And also, I found that Net::Telnet may have some problem in dealing with TCP packets, sometime it just mis-treat a packet end as a EOF and return the incomplete content to me when there are still some packets to read. The timeout value is enough for it, I am sure.

Replies are listed 'Best First'.
Re^3: How to grab the telnet screen output?
by glide (Pilgrim) on Jan 29, 2008 at 09:54 UTC
    Hi,

    Normally, I use the waitfor to match a temporary changed "prompt", like a --more--. And, as you can read in the Net::Telnet with

    ($prematch, $match) = $obj->waitfor($matchop); $obj->print(q{a}) if( $prematch =~ m{f\. Advanced}sm ); $obj->print(q{b}) if( $prematch =~ m{l\. Command Line}sm );
    you can use the $prematch to get the context.

    Probably, your problem it's not with the TCP packets and the Net::Telnet, but with a premature match. Use the dump_log to inspect the flow of the session, and last, but not the least, use the perl -d to check each telnet interaction.