From 17ad3d64293b64f70ad9296164a07eb0b704b8bc Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 18 Oct 2012 21:01:34 +0200 Subject: [PATCH] Throw an Exception if the runhelper is not installed on a node --- frontend/classes/class.sshconnector.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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) {