[icinga-checkins] icinga.org: icinga-web/master: * SSH returnvalues fix (THANKS TG)

git at icinga.org git at icinga.org
Fri Jan 27 15:19:46 CET 2012


Module: icinga-web
Branch: master
Commit: a9f2f0116c9eba776bbe4bec34ce5912803319e2
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=a9f2f0116c9eba776bbe4bec34ce5912803319e2

Author: Marius Hein <marius.hein at netways.de>
Date:   Fri Jan 27 15:19:28 2012 +0100

* SSH returnvalues fix (THANKS TG)

---

 .../Api/lib/console/SshConsoleConnection.class.php |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/app/modules/Api/lib/console/SshConsoleConnection.class.php b/app/modules/Api/lib/console/SshConsoleConnection.class.php
index c473110..3707c61 100644
--- a/app/modules/Api/lib/console/SshConsoleConnection.class.php
+++ b/app/modules/Api/lib/console/SshConsoleConnection.class.php
@@ -83,15 +83,14 @@ class SshConsoleConnection extends BaseConsoleConnection {
     public function exec(Api_Console_ConsoleCommandModel $cmd) {
         $this->connect();
         $cmdString = $cmd->getCommandString();
-        $out = $this->resource->exec($cmdString);
+        $out = $this->resource->exec($cmdString . '; echo -n "|$?"');
+        $lines = preg_split('/\|/', $out);
+        $ret = (int) array_pop($lines);
+        $out = implode('|', $lines);
         $cmd->setOutput($out);
-        $cmd->setReturnCode($this->getLastReturnValue());
+        $cmd->setReturnCode($ret);
     }
 
-    public function getLastReturnValue() {
-        $retVal = $this->resource->exec("echo $?".PHP_EOL); 
-        return $retVal;
-    }
     public function __construct(array $settings = array()) {
         $settings = $settings["auth"];
         





More information about the icinga-checkins mailing list