【发布时间】:2012-08-05 18:11:04
【问题描述】:
我正在使用 Web 前端使用 Net::OpenSSH 执行远程命令。我的命令在命令行上没有失败地返回,但我在网络浏览器中什么也得不到。我做了几个小时的研究无济于事——有什么想法吗?
这里有一些代码给你一个例子(一些明显的原因被删除了)。
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
use Net::OpenSSH;
# Here in the code is just the header and standard tags
print "1";
print "2"; # both display
my $ssh = Net::OpenSSH->new($host, user => $uname, key_path => $key); # all works
$ssh- error and die "Can't ssh to host" . $ssh->error;
print "3";
$ssh->system("uname -a") or
die "remote command failed: " . $ssh->error;
my @lsa = $ssh->capture("ls -a");
$ssh->error and
die "remote ls command failed: ". $ssh->error;
print "4";
print "5";
print @lsa; # won't display in browser, just terminal/CLI
干杯!
【问题讨论】:
-
$ssh- error and die?样本中的错字或更糟? :) -
另外,服务器错误日志说什么?
-
服务器和操作系统是什么?