ElectricCheese has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Telnet command with more than 1024 chars (updated)
by thanos1983 (Parson) on Jul 19, 2017 at 13:59 UTC | |
by ElectricCheese (Initiate) on Jul 19, 2017 at 18:38 UTC | |
by thanos1983 (Parson) on Jul 19, 2017 at 23:04 UTC | |
by ElectricCheese (Initiate) on Jul 25, 2017 at 19:49 UTC | |
by soonix (Chancellor) on Jul 20, 2017 at 11:52 UTC | |
by ElectricCheese (Initiate) on Jul 25, 2017 at 19:17 UTC | |
|
Re: Telnet command with more than 1024 chars
by karlgoethebier (Abbot) on Jul 19, 2017 at 16:42 UTC |