+ -
当前位置:首页 → 问答吧 → perl telnet 发送条指令超时问题(重分酬谢)

perl telnet 发送条指令超时问题(重分酬谢)

时间:2010-11-18

来源:互联网

 
我是向交换机发送多条指令.
第一个指令返回的数据比较长,要分屏显示.为什么总会有
NETELNETD_FAILD
执行命令DSP CFG:;超时(30秒)【网元:2029873079】。


  指令超时是什么意思?怎么解决?


Perl code
for(my $u=3;$u <$count_cmdd;$u++) 
{
print "array_cmdd: $array_cmdd[$u]\n";

my $timeoutt = 30; # seconds

eval {

local $SIG{ALRM} =

sub { die "Sorry, timed out. Please try again\n" };

alarm $timeoutt;

execCmd($array_cmdd[$u],$u,$t,$restypeid);#我的处理子程序


alarm 0;

};

$t->buffer_empty;

}


sub execCmd{

my ($cmd,$u,$mythread,$typeid) = @_;
my $pre_match_lines;
my $match;

print "execmd $cmd ,$u,\n";

TXT("execmd $cmd,$u\n");



my @linelist = $mythread->cmd("execmd $cmd");


while(my $data=$mythread->get('Timeout'=>10))#设置一个合适的超时,不至于使程序没运行结束而终止等待

{
print($data);

TXT("$data");

if($data=~/reports in total/ and $u eq 3)#此处判断何时程序运行结束
{
return 1;
}
if($data=~/--- END/ and $u > 3)
{
return 1;
}
else
{
return 0;
}



}

}

作者: whynotldch   发布时间: 2010-11-18

可能在匹配返回串时超时吧。

作者: fibbery   发布时间: 2010-11-20

太专用的程序不方便帮你调试。

作者: fibbery   发布时间: 2010-11-20