Running Remote using Perl CGI

Hello All,

I have Perl CGI Script which is running the command on the Remote
command
and display output on the webpage.Script is failing with below
error…

cannot connect to filer 192.168.xxx.xxx at /var/www/cgi-bin/export.cgi
line
14.

Same Script works fine when i run the script from the command prompt…

Apache running with the “deamon” user.As we have standard apache
configuration,It’s not possible for me change the apache
configuration(apache user,path change).
I need to run the similar command on 1000+ storages.already ssh keys
enabled
for the root user.So i would like use “root” user to run the remote
commands.

I have given the complete script below…

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Net::OpenSSH;
my $hostname=“192.168.xxx.xxx”;
my %opts = (
user => “root”,
key_path => “/root/.ssh/id_rsa”,
strict_mode => 0
);
$obj=new CGI;
my $ssh=Net::OpenSSH->new($hostname,%opts);
$ssh->error and die “cannot connect to filer $hostname “;
$test=$ssh->capture(“version”);
print $obj->header(),
$obj->start_html(-title=>‘Export Script’),
$obj->center($obj->h2(‘Export list’)),
$obj->start_html(-title=>‘Export Script’),
$obj->center($obj->h2(‘Export Script’)),
$obj->i(”$test”),
$obj->end_html();

it’s completly blocking my work.Please help me asap.

Posted at Nginx Forum:

Hello All,

I have Perl CGI Script which is running the command on the Remote Server
and
display output on the webpage.Script is failing with below error…

cannot connect to filer 192.168.xxx.xxx at /var/www/cgi-bin/export.cgi
line
14.

Same Script works fine when i run the script from the command prompt…

Apache running with the “deamon” user.As we have standard apache
configuration,It’s not possible for me change the apache
configuration(apache user,path change).
I need to run the similar command on 1000+ storages.already ssh keys
enabled
for the root user.So i would like use “root” user to run the remote
commands.

I have given the complete script below…

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Net::OpenSSH;
my $hostname=“192.168.xxx.xxx”;
my %opts = (
user => “root”,
key_path => “/root/.ssh/id_rsa”,
strict_mode => 0
);
$obj=new CGI;
my $ssh=Net::OpenSSH->new($hostname,%opts);
$ssh->error and die “cannot connect to filer $hostname “;
$test=$ssh->capture(“version”);
print $obj->header(),
$obj->start_html(-title=>‘Export Script’),
$obj->center($obj->h2(‘Export list’)),
$obj->start_html(-title=>‘Export Script’),
$obj->center($obj->h2(‘Export Script’)),
$obj->i(”$test”),
$obj->end_html();

it’s completly blocking my work.Please help me asap.

Posted at Nginx Forum: