Friday, August 17, 2018

Trigger my shell script which is available in remote server using Phpseclib

I am very much new with Phpseclib, and I am trying to sh/execute shell script available on my remote server using Phpseclib

set_include_path(get_include_path() . PATH_SEPARATOR . 'lib/phpseclib1.0.5');
include('lib/phpseclib1.0.5/Net/SSH2.php');
define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
include_once ("admin/model/JobDAO.php");
$ssh = new Net_SSH2('192.168.11.68');
if (!$ssh->login('amit', 'password')) {
exit('Login Failed');
}
$ssh->setTimeout(1000);
$deployment_script="./InstallJava-Final.sh";
$ssh->exec(
    $deployment_script, function ($str) {
        echo $str;
        flush();
        ob_flush();
    });

?>

Above PHP code trigger my shell script InstallJava-Final.sh which is available in the remote server and show the output on the browser that It's downloading java from oracle website using wget but few second later the process Stopped.

browser output

My remote script should run properly without interruption/stop with root user

No comments:

Post a Comment