如何设置perl Net :: Telnet窗口的大小以打印超过80个字符的行

时间:2014-12-12 21:30:51

标签: perl telnet

此脚本的输出已包装,我不想要。

use strict;
use Net::Telnet;
system("mode 500,6000");
print "passwd: ";
my $passwd=<>;
chomp($passwd);
my $telnet = Net::Telnet->new(Host=>'linux63.blahblah.edu',Prompt=>'/l+inux63> $/');
$telnet->waitfor('/login/');
$telnet->print("myusername");
$telnet->waitfor('/Password/');
$telnet->print("$passwd\n");
$telnet->waitfor('/linux63/');
my @lines = $telnet->cmd("somecommand");
#etc
$telnet->print("logout\n");

此脚本的输出打印为:

This is the output of some command, has more than 80 characters in this line whic

h should not be broken

我想要它如下,任何帮助?

This is the output of some command, has more than 80 characters in this line which should not be broken

脚本中使用的mode命令以下没有帮助。

system("mode 500,6000");

1 个答案:

答案 0 :(得分:0)

看起来Net :: Telnet支持选项协商,RFC 1073是telnet窗口大小选项的标准。您应宣传WILL NAWS,并使用DO NAWS(宽度)(高度)IAC SB NAWSIAC SE回复服务器请求,其中宽度和高度编码为16位大端(n模板到pack)。