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

Hi monks,

I am using Net::Telnet. I am telneting into my server to get statistics and I am trying to save it to an array and display that array.
Other commands are working fine and I can store it into an array and I am able to display.
But for a particular one command , I am getting an error that "maximum input buffer length exceeded: 1048576 bytes".
How can I increase the buffer size ?
I tried :

my $obj = Net::Telnet->new( Timeout => 10, Errmode => 'return', Max_bu +ffer_length => 50*1024*1024, Prompt => 'SomePromptthatworkswell');

I know that output of the commad is pretty big. But I dont know how to work around to increase the buffer size. Any help would be appreciated.
Thanks, NK

Replies are listed 'Best First'.
Re: telnet max buffer exceeded
by graff (Chancellor) on May 17, 2014 at 02:28 UTC
    Contrary to what BrowserUK said, it seems like your usage is consistent with what Net::Telnet expects. Having looked at the source code, "-max_buffer_length" and "-Max_Buffer_Length" should also work. Or, you could use the method call on the object itself:
    my $obj = Net::Telnet->new( … ); $obj->max_buffer_length( 50*1024*1024 );
    But I would be very surprised if that behaved any differently.

    It would be helpful to know how you are trying to fetch the input into your script. If you aren't using $obj->get(); maybe you should be. If you're using any sort of line-oriented method, it does seem strange that a remote process could spew many MB of data without ever emitting something that looks like a line termination, but that could happen.

    Anyway, if that's what you're dealing with, obj->get() will just give you arbitrary pieces as you call it (and as input becomes available). I presume you know what you're supposed to do with such data, and can figure out how to parse your way through the pieces...

      After successfully logging in to my server I am using:
      I am using my @randomarray = $obj-> cmd ("Some command") ;

      I do not have to wait for input to become available. It is just that input is way too big. I will try your method above and let you know if that works.
      Thanks \m/

      Works :D
      Thanks, graff :D :D :D
Re: telnet max buffer exceeded
by BrowserUk (Patriarch) on May 16, 2014 at 22:32 UTC
    Max_buffer_length

    Try that with a lower-case m?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Tried upper case and lower case but doesn't work. Error I am getting is bad parameter.