GC_Filesystem_SSH2::run_command()
最后更新于:2021-11-27 20:49:35
GC_Filesystem_SSH2::run_command( string$command, bool$returnbool=false)参数
- $command
-
(string) (Required)
- $returnbool
-
(bool) (Optional)
Default value: false
响应
(bool|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.
源文件
文件: gc-admin/includes/class-gc-filesystem-ssh2.php
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;
}