Closed mlocati closed 1 year ago
Never mind, I checked the source code and I saw that since version 0.13 this can be already done:
$connection = ssh2_connect($host);
ssh2_auth_password($connection, $username, $password);
$channel = ssh2_exec($connection, $command);
$metadata = stream_get_meta_data($channel);
$exitCode = $metadata['exit_status'];
fclose($channel);
What about adding a new function to retrieve the exit code if a command executed with
ssh2_exec()
?I'm thinking about a new
ssh2_get_exit_status()
function that could be used like this:And internally,
ssh2_exec()
could uselibssh2_channel_get_exit_status()
.