Welcome! Log In Create A New Profile

Advanced

Re: Running Remote command using Perl CGI

January 19, 2015 04:58AM
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.
Subject Author Posted

Running Remote using Perl CGI

srinumar January 19, 2015 04:56AM

Re: Running Remote command using Perl CGI

srinumar January 19, 2015 04:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready