[Ssh-sftp-perl-users] using Net::SSH::Perl from a web page
Brought to you by:
dbrobins
|
From: Caron, C. <ch...@NR...> - 2004-09-21 16:56:15
|
Hi,
I'm trying to use Net::SSH::Perl to connect to a remote server via a web
page. The webserver is running as an unprivileged user (webserve).
This code does work fine from the command line (as user webserve), but when
I try the same code from the web interface, it prints everything up to the
$ssh->cmd() line...
Is this a security feature? Any solution for something like this to work?
Thanks!
=============================================
Code:
---------------------------------------------
#!/usr/local/bin/perl
use Net::SSH::Perl;
use strict;
my $server = 'server';
my $un = 'username';
my $pw = 'password';
print "Content-type: text/html\n\n";
print "<html><body>\n";
print "Testing Net::SSH::Perl\n";
my $ssh = Net::SSH::Perl->new("$server", port=>'22', protocol=>'1,2');
print "1...<br>";
$ssh->login($un, $pw);
print "2...<br>";
my ($stdout, $stderr, $exit) = $ssh->cmd("ls");
print "3...<br>";
print "stdout is $stdout<br>\n";
print "stderr is $stderr<br>\n";
print "exit is $exit\n";
print "</body></html>";
=============================================
=============================================
Output from command line:
---------------------------------------------
name# perl x.cgi
Content-type: text/html
<html><body>
Testing Net::SSH::Perl
1...<br>2...<br>3...<br>stdout is CSSdomain_01.sql
check_version_unix.cgi
list
manic
public_html
reindex
scripts
test
<br>
stderr is <br>
exit is 0
</body></html>
=============================================
=============================================
Output from web page (source):
---------------------------------------------
<html><body>
Testing Net::SSH::Perl
1...<br>2...<br>
=============================================
-
Christian Caron
|