I'm seeking knowledge to guide me through this dense mist...

I discovered the telnet server on which I connect (Windows Server (probably 2013)), any command sent must have at maximum 1024 characters, anything more than this, the server asks me for "More? ", and then I should input the remaining characters and press enter. So far, so good.

I have a program written in Perl, that executes a series of commands in this server, but recently some commands have been stuck until it times out, and I discovered that are the commands with more than 1024 characters.

So, I decided to rewrite the execution function to support this behavior, but any one of methods tried didn't worked.

This is how I normally execute my commands before:

my $t = new Net::Telnet(Telnetmode => 1, Errmode => 'return'); $t->prompt('/C:\\\\(.*)>/i'); $t->open(Host => '192.168.0.10'); $ok = $t->login('myUsername', 'myPassword'); my $cmd = "blah blah blah (...)"; # 1287 characters of a VALID comm +and my @r = $t->cmd(String => $cmd, Timeout => 60);

This will result in timeout. If the command have at maximum of 1024 characters, it passes normally.

Then I decided use this way, instead of  $t->cmd()

my @r = $t->print(String => $cmd, Timeout => 60); ($prematch, $match) = $t->waitfor(String => 'More? ', Timeout=>60) +or die("MORE NOT FOUND");

And the waitfor times out... I'm pretty lost here.

So my questions are:

1) Am I missing anything about telnet and the limitation of 1024 input characters? So maybe this could be solved by using a different configuration? I have googled a lot about this subject and found't anything useful...

2) Is the commands $t->print() and $t->waitfor() right?

Where do we go from here?

Thanks for your help monks!


In reply to Telnet command with more than 1024 chars by ElectricCheese

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.