Net::Telnet output of cmd timed-out

左心房为你撑大大i 提交于 2019-12-25 05:31:55

问题


I tried to build a little telnet script to gain contact with the Net::Telnet module in Perl and I struggle with a command timeout when I try to receive the output.

$telnet = new Net::Telnet ( Timeout=>10);
$telnet->errmode("return");
$telnet->open('192.168.0.187');
$telnet->waitfor('/Username: $/i');
$telnet->print('admin');
$telnet->waitfor('/Password: $/i');
$telnet->print('admin');
$telnet->waitfor('/admin  >$/i');
@output = $telnet->cmd('show');
#$telnet->waitfor('/admin  >$/i');
print @output;

But what I get is:

command timed-out at telnet.pl line 12

Tried to increase the Timeout, set the errmode to return - but still getting that timeout. Nevertheless the output of "show" on the server needs about 1 sec, so something else must be wrong I guess in my script ?


回答1:


Please tell us what line 12 in your script is. Your snippet above doesn't have a line 12.

This will help to identify whether it fails during the connect already or during a later command. Are you sure it's the "show" command which fails?



来源:https://stackoverflow.com/questions/12049655/nettelnet-output-of-cmd-timed-out

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!