SSH working

feature/node-rewrite
Sven Slootweg 13 years ago
parent 7a397233a4
commit 60e9eb60b5

@ -33,7 +33,7 @@ class SshConnector extends CPHPBaseClass
try try
{ {
$this->Connect(); $this->Connect();
$this->DoCommand($command); return $this->DoCommand($command);
} }
catch (SshConnectException $e) catch (SshConnectException $e)
{ {
@ -50,7 +50,7 @@ class SshConnector extends CPHPBaseClass
{ {
try try
{ {
$this->DoCommand($command); return $this->DoCommand($command);
} }
catch (SshCommandException $e) catch (SshCommandException $e)
{ {
@ -100,7 +100,12 @@ class SshConnector extends CPHPBaseClass
private function DoCommand($command) private function DoCommand($command)
{ {
$stream = ssh2_exec($this->connection, $command); $stream = ssh2_exec($this->connection, $command);
var_dump($stream); stream_set_blocking($stream, true);
$returndata = stream_get_contents($stream);
fclose($stream);
return $returndata;
} }
} }

@ -7,7 +7,5 @@ $ssh->host = "cvm-vz.cryto.net";
$ssh->key = "/etc/cvm/key"; $ssh->key = "/etc/cvm/key";
$ssh->pubkey = "/etc/cvm/key.pub"; $ssh->pubkey = "/etc/cvm/key.pub";
var_dump($ssh); var_dump($ssh->RunCommand("df -h"));
$ssh->RunCommand("df -h");
?> ?>

Loading…
Cancel
Save