diff --git a/frontend/classes/class.sshconnector.php b/frontend/classes/class.sshconnector.php index 0cf2fe5..8b07fc5 100644 --- a/frontend/classes/class.sshconnector.php +++ b/frontend/classes/class.sshconnector.php @@ -105,13 +105,25 @@ class SshConnector extends CPHPBaseClass $command = "{$this->helper} {$command}"; $stream = ssh2_exec($this->connection, $command); + $error_stream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR); + stream_set_blocking($stream, true); + stream_set_blocking($error_stream, true); + + $result = stream_get_contents($stream); + $error = stream_get_contents($error_stream); + + if(strpos($error, "No such file or directory") !== false) + { + throw new Exception("The runhelper is not installed on the node."); + } - $returndata = json_decode(stream_get_contents($stream)); + $returndata = json_decode($result); $returndata->stderr = trim($returndata->stderr); fclose($stream); + fclose($error_stream); if($returndata->returncode != 0 && $throw_exception === true) {