use Net::OpenSSH;
my $host = "$ip";
my $user = 'root';
my $passphrase = 'uxxxxxD';
my $key = '/root/.ssh/id_rsa';
my $cmd="sh $script";
my %param = (
             user => $user,
             passphrase => $passphrase,
             key_path => $key,
             timeout => 100
             );
my $ssh = Net::OpenSSH->new($host,%param);
my ($stdout,$stderr,$exit) = $ssh->capture2("$cmd");
my $exit = ($? >> 8);
print "\$exit is $exit\n";
sleep (10);
if($exit == 0){
   print "publish success\n";
print $stdout;
open( F, ">>", "/home/scan/mojo/log/$app-$ip-$XDATE.log" );
print F ("ErrorCode:$exit\n");
print F ("ErrorMsg:$stderr\n");
print F ("$stdout\n");
close F;
$c->render(text =>  'publish success')
    } else {
    print $ssh->error;
    $stderr and print $stderr;
	open( F, ">>", "/home/scan/mojo/log/$app-$ip-$XDATE.log" );
print F ("ErrorCode:$exit\n");
print F ("ErrorMsg:$stderr\n");
print F ("$stdout\n");
close F;

 $c->render(text =>  "ErrorCode:$exit;ErrorMsg:$stderr")
    }