From 60e9eb60b56bb72e69a287816d32c880e624aaae Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 29 Apr 2012 04:00:07 +0200 Subject: [PATCH] SSH working --- frontend/classes/class.sshconnector.php | 11 ++++++++--- frontend/test.php | 4 +--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/classes/class.sshconnector.php b/frontend/classes/class.sshconnector.php index 15913a2..7cfeab4 100644 --- a/frontend/classes/class.sshconnector.php +++ b/frontend/classes/class.sshconnector.php @@ -33,7 +33,7 @@ class SshConnector extends CPHPBaseClass try { $this->Connect(); - $this->DoCommand($command); + return $this->DoCommand($command); } catch (SshConnectException $e) { @@ -50,7 +50,7 @@ class SshConnector extends CPHPBaseClass { try { - $this->DoCommand($command); + return $this->DoCommand($command); } catch (SshCommandException $e) { @@ -100,7 +100,12 @@ class SshConnector extends CPHPBaseClass private function DoCommand($command) { $stream = ssh2_exec($this->connection, $command); - var_dump($stream); + stream_set_blocking($stream, true); + + $returndata = stream_get_contents($stream); + + fclose($stream); + return $returndata; } } diff --git a/frontend/test.php b/frontend/test.php index b07ef44..4a5083b 100644 --- a/frontend/test.php +++ b/frontend/test.php @@ -7,7 +7,5 @@ $ssh->host = "cvm-vz.cryto.net"; $ssh->key = "/etc/cvm/key"; $ssh->pubkey = "/etc/cvm/key.pub"; -var_dump($ssh); - -$ssh->RunCommand("df -h"); +var_dump($ssh->RunCommand("df -h")); ?>