WP_Filesystem_SSH2::run_command()
Method of the class: WP_Filesystem_SSH2{}
No Hooks.
Return
true|false|String
. True on success, false on failure. String if the command was executed, $returnbool is false (default), and data from the resulting stream was retrieved.
Usage
$WP_Filesystem_SSH2 = new WP_Filesystem_SSH2(); $WP_Filesystem_SSH2->run_command( $command, $returnbool );
- $command(string) (required)
- -
- $returnbool(true|false)
- -
Default: false
Changelog
Since 2.7.0 | Introduced. |
WP_Filesystem_SSH2::run_command() WP Filesystem SSH2::run command code WP 6.5.2
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 { stream_set_blocking( $stream, true ); stream_set_timeout( $stream, FS_TIMEOUT ); $data = stream_get_contents( $stream ); fclose( $stream ); if ( $returnbool ) { return ( false === $data ) ? false : '' !== trim( $data ); } else { return $data; } } return false; }