我正在使用Net :: OpenSSH使用Web前端执行远程命令。我的命令在命令行上没有失败地返回,但是在Web浏览器中我什么也得不到。我已经做了几个小时的研究无济于事 - 有什么想法?在浏览器中显示输出Perl CGI SSH
下面是一些代码给你一个例子(一些显而易见的原因被删除)。
#!/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'?样本中的拼写错误还是更糟? :) – 2012-08-08 16:10:50
另外,服务器错误日志说什么? – 2012-08-08 16:11:53
什么是服务器和操作系统? – 2012-08-08 16:12:38