Net::SSH::Perl 手无输出 [英] Net::SSH::Perl hands without output

查看:43
本文介绍了Net::SSH::Perl 手无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 windows 和 unix 框获取连接,然后只传递一个 ls 命令.执行只是挂起,没有任何输出.可能有什么问题?

Hi I am trying to get a connection from windows a unix box and just pass an ls command. The execution just hangs without any output. What might be wrong?

#!/usr/bin/perl -w
use strict;

use Net::SSH::Perl;

my $hostname = "unixhost";
my $username = "####";
my $password = "######";

my $cmd = shift;


my $ssh = Net::SSH::Perl->new("$hostname", debug=>1,  identity_files => []);
$ssh->login("$username","$password");
my ($stdout,$stderr,$exit) = $ssh->cmd("$cmd");
print $stdout;
exit;

*> C:>perl ssh.pl "ls -ltr"WXVM0026:读取配置数据

*> C:>perl ssh.pl "ls -ltr" WXVM0026: Reading configuration data

c:/.ssh/config WXVM0026:读取配置数据/etc/ssh_configWXVM0026:连接到他们的端口 22. WXVM0026:远程协议版本 1.99,远程软件版本OpenSSH_4.5p1+sftpfilecontrol-v1.1-hpn12v14 WXVM0026:Net::SSH::Perl版本 1.34,协议版本 1.5.WXVM0026:没有兼容匹配:OpenSSH_4.5p1+sftpfilecontrol-v1.1-hpn12v14.WXVM0026:连接已确立的.WXVM0026:正在等待服务器公钥.WXVM0026:收到服务器公钥(768 位)和主机密钥(1024 位).WXVM0026:主机themse"已知且与主机密钥匹配.WXVM0026:加密类型:DES3 WXVM0026:发送加密会话密钥.WXVM0026:收到加密确认.WXVM0026:进行质询响应验证.密码: 密码:WXVM0026:发送命令:ls -ltrWXVM0026:正在进入交互式会话.*

c:/.ssh/config WXVM0026: Reading configuration data /etc/ssh_config WXVM0026: Connecting to themse, port 22. WXVM0026: Remote protocol version 1.99, remote software version OpenSSH_4.5p1+sftpfilecontrol-v1.1-hpn12v14 WXVM0026: Net::SSH::Perl Version 1.34, protocol version 1.5. WXVM0026: No compat match: OpenSSH_4.5p1+sftpfilecontrol-v1.1-hpn12v14. WXVM0026: Connection established. WXVM0026: Waiting for server public key. WXVM0026: Received server public key (768 bits) and host key (1024 bits). WXVM0026: Host 'themse' is known and matches the host key. WXVM0026: Encryption type: DES3 WXVM0026: Sent encrypted session key. WXVM0026: Received encryption confirmation. WXVM0026: Doing challenge response authentication. Password: Password: WXVM0026: Sending command: ls -ltr WXVM0026: Entering interactive session.*

推荐答案

如果远程命令没有关闭它的输入/输出/stederr,SSH 会话将永远等待它的输入(至少直到它的超时).

If the remote command does not close its input/output/stederr the SSH session waits for its input forever (at least until its timeoouts).

 my $cmd = "ls / 0<&- 1>&- 2>&-";

问候,

这篇关于Net::SSH::Perl 手无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆