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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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 更高ping网络上的Net::SSH2_Perl_Ssh - Fatal编程技术网

Perl 更高ping网络上的Net::SSH2

Perl 更高ping网络上的Net::SSH2,perl,ssh,Perl,Ssh,从中读取似乎会给出一个空列表,并且这种情况主要发生在延迟较高的网络上的主机上。是否有更可靠的方式与远程主机交互 use Net::SSH2; # my $ssh = Net::SSH2->new(); # ... my $chan = $ssh->channel() or die "no channel\n"; $chan->blocking(1); # even worse with $chan->blocking(0); $chan->shell(); p

中读取似乎会给出一个空列表,并且这种情况主要发生在延迟较高的网络上的主机上。是否有更可靠的方式与远程主机交互

use Net::SSH2;

# my $ssh = Net::SSH2->new();
# ...

my $chan = $ssh->channel() or die "no channel\n";
$chan->blocking(1); # even worse with $chan->blocking(0);
$chan->shell();

print $chan "ps -ef\n";
print <$chan>;
使用

几天前,我发布了版本0.04,修复了我们之前讨论的两个问题:

  • 未选中的对
    频道的调用
  • Net::SSH2
    后端上的超时支持。它仍然不是完美的,因为OpenSSH和libssh2都不支持向远程进程发送信号以终止它,因此,模块只是关闭stdio流,并希望远程程序在下次尝试写入时最终会收到SIGPIPE
    • 使用

      几天前,我发布了版本0.04,修复了我们之前讨论的两个问题:

      • 未选中的对
        频道的调用
      • Net::SSH2
        后端上的超时支持。它仍然不是完美的,因为OpenSSH和libssh2都不支持向远程进程发送信号以终止它,因此,模块只是关闭stdio流,并希望远程程序在下次尝试写入时最终会收到SIGPIPE

      通过Net::SSH2::Channel对象与远程shell通信非常困难。请改用。@salva我正在考虑切换到您的
      Net::OpenSSH
      模块。我想
      capture()
      pipe\u out()
      工作得更好?它们更易于使用,您必须自己在低级原语之上编写它们。唯一真正的问题是它在Windows上不工作。@salva是的,我看到它在win32上不工作。顺便说一句,
      Net::SSH2::Simple
      看起来很有趣。看看Net::SSH2::Simple源代码,我发现它有很多缺陷。例如,它不处理错误,超时也不起作用。通过Net::SSH2::Channel对象与远程shell通信是相当困难的。请改用。@salva我正在考虑切换到您的
      Net::OpenSSH
      模块。我想
      capture()
      pipe\u out()
      工作得更好?它们更易于使用,您必须自己在低级原语之上编写它们。唯一真正的问题是它在Windows上不工作。@salva是的,我看到它在win32上不工作。顺便说一句,
      Net::SSH2::Simple
      看起来很有趣。看看Net::SSH2::Simple源代码,我发现它有很多缺陷。例如,它不处理错误,超时也不起作用
      sub _capture {
          my ($any, $opts, $cmd) = @_;
          my $ssh2 = $any->{be_ssh2} or return;
          my $channel = $ssh2->channel;
          my ($out_fh, $err_fh) = __parse_fh_opts($any, $opts, $channel) or return;
          $out_fh and die 'Internal error: $out_fh is not undef';
      
          # vvvvvvvvvvvvvv
          $channel->exec($cmd); # <--- LINE 133
          # ^^^^^^^^^^^^^^
      
          (__io3($any, $ssh2, $channel, $opts->{stdin_data}, undef, $err_fh || \*STDERR))[0];
      }