如何调试 Perl Net::Telnet 程序?
我正在尝试自动远程登录到 Linux 机器,该机器不需要通过 Net:: 进行任何身份验证Telnet Perl 模块。这是一个测试脚本:
use strict;
use Net::Telnet;
my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die',
host=> '10.104.20.200', port => 2004,
);
$telnet->print('ls');
my $output = $telnet->waitfor('/\$ $/i');
print $output;
当我执行此脚本时,出现以下错误,
pattern match timed-out at telnetPerl.pl line 7.
如您所见,我匹配 waitfor
中的任何字符。但我怀疑 telnet 连接是否首先发生。
I am trying to automate telnet to a Linux box which doesn't require any authentication through Net::Telnet Perl module. Here is a test script:
use strict;
use Net::Telnet;
my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die',
host=> '10.104.20.200', port => 2004,
);
$telnet->print('ls');
my $output = $telnet->waitfor('/\$ $/i');
print $output;
When I execute this script, I get the below error,
pattern match timed-out at telnetPerl.pl line 7.
As you could see, I am matching for any characters in waitfor
. But I doubt whether the telnet connectivity happened in the first place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Net::Telnet 文档在
waitfor()< 条目下显示/代码>:
当您按照医生的指示进行操作时发生了什么? :)
The Net::Telnet docs say under the entry for
waitfor()
:What happened when you followed the doc's instructions? :)