Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 如果远程节点请求_Perl - Fatal编程技术网

Perl 如果远程节点请求

Perl 如果远程节点请求,perl,Perl,我需要向远程设备发送命令,当它要求按CTRL+C键中断时,另一个键继续。。。我应该再次向远程设备发送回车键 我写了下面的Scriptpt,但不知怎的它不起作用 my $session = new Net::Telnet ( Timeout => 30, Prompt=> '/>/', Input_log =>\*STDOUT ); $session->open('device-id'); $session->login('admi

我需要向远程设备发送命令,当它要求按CTRL+C键中断时,另一个键继续。。。我应该再次向远程设备发送回车键

我写了下面的Scriptpt,但不知怎的它不起作用

my $session = new Net::Telnet (
    Timeout => 30, 
    Prompt=> '/>/', 
    Input_log  =>\*STDOUT
);
$session->open('device-id');
$session->login('admin','admin');

print "connected and logged in \n\n"; 
print "Kindly wait till output stored in FILE \n\n";

my @output1=$session->cmd('DSP PATCH:;');
if ($session->waitfor('/Press CTRL+C to break, other key to continue.../')) {
    $session->print('');   # Assuming default is \n for print command
}

print @output1;
上述脚本的输出为

然后它超时了

知道如何发送enter hit直到我的远程设备要求我按enter键吗。

cmd方法发送命令并等待提示。相反,可以使用print和wait运行命令,以便保存返回的prematch,也可以使用远程消息覆盖cmd调用的提示。我建议做前者。

您是否检查过使用$session->dumplog进行调试

试试这个::my$telnet=Net::telnet->newTimeout=>30,Errmode=>return';


摘自

谢谢hasturkun,在你的建议下,我成功点击了enter via。脚本…现在的问题是如何存储所有输出到一个文件…它打印输出后,点击回车。。。my@output=$session->打印“DSP补丁:;”;而$session->waitfor'/continue/'{push@output,$session->print;push@output,$session->waitfor'/continue/';}如果有人帮助如何存储标准输出中包含的所有内容,我的问题将得到解决…好的,我通过…Input_log=>*FILE1获得它,它将所有输出存储到文件句柄:FILE1………非常感谢您的帮助…问候:Mahesh
connected and logged in

Kindly wait till output stored in FILE

.

.

some output of command send...........

.
Press CTRL+C to break, other key to continue...