Ejemplo n.º 1
0
 /**
  * @param $cmd
  * @param bool $pty
  * @param null $env
  * @return string
  * @throws RemoteShellCommandException
  */
 public function exec($cmd, $pty = FALSE, $env = NULL)
 {
     $result = ssh2_exec($this->connection->getConnection(), $cmd, $pty, $env);
     $errorStream = ssh2_fetch_stream($result, SSH2_STREAM_STDERR);
     stream_set_blocking($errorStream, TRUE);
     stream_set_blocking($result, TRUE);
     $error = stream_get_contents($errorStream);
     if (!empty($error)) {
         throw new RemoteShellCommandException($error);
     }
     return stream_get_contents($result);
 }
Ejemplo n.º 2
0
 /**
  * @return resource
  */
 protected function getSftpResource()
 {
     if (!$this->sftp) {
         $this->sftp = ssh2_sftp($this->connection->getConnection());
     }
     return $this->sftp;
 }