I want to get the exit status of ssh2_exec command.I tried following code but it it is giving me the output of jar file but i want only the status for success or failure.How can i get that, please help.
$stream = ssh2_exec($connection, 'path of jar file');
stream_set_blocking($stream,true);
$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDIO);
echo stream_get_contents($output);
You should use stderr instead:
$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR);
If there are no errors, it's a success.