+ -
当前位置:首页 → 问答吧 → 求救。。。Net::SSH::Perl 模块的问题。。。

求救。。。Net::SSH::Perl 模块的问题。。。

时间:2010-11-25

来源:互联网

我想用这个模块来连接远程主机并执行命令,程序能成功连接上主机。。但是执行一个命令的时候。。就刮起了。。。一直等不到结果啊。。程序如下:
#!/usr/bin/perl -w
use strict;
use Net::SSH:Perl;

$ENV{"TERM"} = "xterm";
my $host = '192.168.1.101';
my $user = 'root';
my $pass = 'iamtzc87';

my %param;
$param{debug} = 1;
$param{protocol} = 2;
$param{port} = 22;
$param{use_pty} = 1;

my $ssh = Net::SSH:erl->new($host,%param);
$ssh->login($user,$pass,0);

my $cmd = 'ls -al';
my ($stdout, $stderr, $ext) = $ssh->cmd($cmd,"\n";
print($stdout, $stderr, $ext);


得到的结果是这样的:
TODDYCE: channel 0: new [client-session]
TODDYCE: Requesting channel_open for channel 0.
TODDYCE: Entering interactive session.
TODDYCE: Sending command: uname -a
TODDYCE: Sending command: uname -a
TODDYCE: Requesting service exec on channel 0.
TODDYCE: channel 0: send eof
TODDYCE: channel 0: open confirm rwindow 2097150 rmax 32768
TODDYCE: channel 0: rcvd eof
TODDYCE: channel 0: output open -> drain
TODDYCE: input_channel_request: rtype exit-status reply 0
TODDYCE: channel 0: rcvd close
这样后就一直挂起了。。。
网上说。。这是Net::SSH:erl 模块的一个bug。。但是也没给出个具体的解决方案。。。

哪位大侠知道怎么解决这个问题啊。。。小弟感激不尽啊!!拜谢!!

作者: toddytao   发布时间: 2010-11-25

帮顶~

作者: smilewtt   发布时间: 2010-11-26