Running Remote command using Perl CGI

srinumar nginx-forum at
Mon Jan 19 09:58:16 UTC 2015

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 at /var/www/cgi-bin/export.cgi line

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

I have given the complete script below..

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Net::OpenSSH;
my $hostname="";
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 ";
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')),

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

Posted at Nginx Forum:,256190,256191#msg-256191

More information about the nginx mailing list