Net::Telnet - problem with very large buffer

From: Paul (pmacadam_at_gmail.com)
Date: 06/25/04


Date: 24 Jun 2004 21:56:04 -0700

Wondering whether anyone has encountered and solved this problem:

I'm using Net::Telnet to collect output from a CLI. It has worked
perfectly for more than a year and a half -- until now.

The command in question produces at least a 1,000 lines of output.
What's strange is absolutely all of the output is in the input_log,
but I cannot get a single character from getline().

Any thoughts / remedies?

Code below:

  $self->{'telnet'}->input_log('/tmp/telnet.in');

  @screen = $self->{'telnet'}->cmd(-string=>$cmd_str,
                                   -cmd_remove_mode=>1,
                                   -prompt=>$self->cli_prompt_str,
                                   -timeout=>90,
                                  );

  # If screen array has only one element
  # that is the empty string,
  # try to drain socket another way

  if ( !(@screen) || ((@screen == 1) && !($screen[0])) ) {
      $self->log('Warning: No data in buffer...');
      while ( (my $line = $self->{'telnet'}->getline(-timeout=>15)) )
{
        push(@screen, $line);
      }
  }

Again, '/tmp/telnet.in' has all of the data that I expect from the
command, but neither cmd() nor getline() seems able to retrieve data.

Am I blowing up Net::Telnet's internal buffer with the large result
set?

PM



Relevant Pages

  • Re: Capture windows command return code to variable in awk script?
    ... needed to close the string that is being piped through getline if that ... string is a file name, but apparently that's true for command line ... Normally, it's good practice to define a string to hold the full command name and use that string for both the open and close, e.g.: ... programB is the only one that exists. ...
    (comp.lang.awk)
  • Re: stringtokenizer
    ... Here I am using getline: ... buffer is an character array, ... | cout << command << endl; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: stringtokenizer
    ... Here I am using getline: ... > | Don't know why this should go wrong but I am getting junk at the command ... > I suspect that you used an character array, ...
    (alt.comp.lang.learn.c-cpp)
  • getline caveats misuse howto: final version
    ... The following, composed by Ed Morton to address the recurring issue of getline use, was based primarily on information from the book "Effective Awk Programming", Third Edition By Arnold Robbins; with review and additional input from many of the comp.lang.awk regulars, including Steve Calfee, ... program rather than learning the easier way that awk was designed to ... "The getline command is used in several different ways and should not be ... getline var < file var ...
    (comp.lang.awk)
  • Re: TSO WLM Transaction Boundaries (was: What do you call something like QMF?)
    ... I am quite familiar with the way that the TMP executes commands. ... The command acquired is executed. ... the TMP issues another GETLINE. ...
    (bit.listserv.ibm-main)