我的perl脚本有问题。脚本在服务器上执行命令,大约需要10-30秒来处理并返回包含70行的输出。
$t = new Net::Telnet (Timeout => 200, dump_log => $file, input_log => $file1, output_log => $file2);
$t->open($host);
$t->waitfor('/User name:$/i');
$t->print($username);
$t->waitfor(match => '/User password:$/i');
$t->print($passwd);
#$t->waitfor('/.*(#|>|\))\s*$/');
@lines = $t->cmd(string => @komenda, Timeout => 4000);
39 $t->waitfor('/----
------------------------------------------------------------------------
-/');
$t->getlines();
print @lines;
模式匹配在efu.pl第39行读取eof
我已将代码更改为
$t = new Net::Telnet (Timeout => 200, dump_log => $file, input_log => $file1, output_log => $file2);
$t->open($host);
$t->waitfor('/User name:$/i');
$t->print($username);
$t->waitfor('/User password:$/i');
$t->print($passwd);
#$t->waitfor('/.*(#|>|\))\s*$/');
39 @lines = $t->cmd(string => @komenda,timeout => 2000);
sleep(50);
#$t->waitfor('/----------------------------------------------------------
-------------------/');
#@linie = $t->getlines();
print @linie;
然后返回
模式匹配在efu.pl第39行读取eof
所有日志文件都包含此命令的输出。
问题出在哪里,我做错了什么?