ssh2_exec example


    public function run_command( $command$returnbool = false ) {
        if ( ! $this->link ) {
            return false;
        }

        $stream = ssh2_exec( $this->link, $command );

        if ( ! $stream ) {
            $this->errors->add(
                'command',
                sprintf(
                    /* translators: %s: Command. */
                    __( 'Unable to perform command: %s' ),
                    $command
                )
            );
        } else {
            

  protected function copyFileJailed($source$destination) {
    if (!@ssh2_scp_send($this->connection, $source$destination)) {
      throw new FileTransferException('Cannot copy @source_file to @destination_file.', 0, ['@source' => $source, '@destination' => $destination]);
    }
  }

  /** * {@inheritdoc} */
  protected function copyDirectoryJailed($source$destination) {
    if (@!ssh2_exec($this->connection, 'cp -Rp ' . escapeshellarg($source) . ' ' . escapeshellarg($destination))) {
      throw new FileTransferException('Cannot copy directory @directory.', 0, ['@directory' => $source]);
    }
  }

  /** * {@inheritdoc} */
  protected function createDirectoryJailed($directory) {
    if (@!ssh2_exec($this->connection, 'mkdir ' . escapeshellarg($directory))) {
      throw new FileTransferException('Cannot create directory @directory.', 0, ['@directory' => $directory]);
    }
  }
Home | Imprint | This part of the site doesn't use cookies.