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

git at icinga.org git at icinga.org
Tue Jan 31 13:51:39 CET 2012


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

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