Remote Executor.
More...
|
| $connection |
|
| $isAuthenticated = false |
|
| $debugLogger |
|
| $errorLogger |
|
Remote Executor.
A parent class with basic functionality to to inheritance and create classes of interaction with remote hosts using remote access protocols (such as TELNET, SSH ...)
- Version
- 1.0
- Author
- Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru
- Copyright
- (c) 2016, SAD-Systems
- Warning
- This class is for inheritance only. Not for directly use.
__construct |
( |
|
$config = null | ) |
|
Constructor
- Parameters
-
array | $config | An array of properties to initialize the class. |
Authenticate the access to remote side.
- Warning
- Method to override
- Returns
- boolean TRUE - Authentication is success.
FALSE - Authentication is fail.
clearBuffers |
( |
|
$type = 'all' | ) |
|
Clear the debug or(and) the error buffer
- Parameters
-
string | $type | Posible values: all|error|debug ; all - by default |
Connect to remote host. Method to override
- Returns
- boolean TRUE - Successfuly connected.
FALSE - Connection is fail.
debug |
( |
|
$message, |
|
|
|
$source = "" |
|
) |
| |
|
protected |
error |
( |
|
$code, |
|
|
|
$source = "" , |
|
|
|
$message = null , |
|
|
|
$detail = null |
|
) |
| |
|
protected |
Create an error
- Exceptions
-
exec |
( |
|
$command, |
|
|
|
$timeout = null |
|
) |
| |
Execute a single command or an array of commands on the remote side.
- Parameters
-
string | array | $command | A command or an array of commands to execute. |
int | $timeout | (Option) Timeout in seconds to wait the response. If it doesn't set the default timeout will be used. |
- Returns
- string|array|false Text data of the response from the remote side. If the
$command
was an array (or string contained "\n") the response data would be an array: [ 0 => 'response to command-1', 1 => 'response to command-2', ... ] Returns FALSE on error.
executeCommand |
( |
|
$command, |
|
|
|
$timeout = null |
|
) |
| |
|
protected |
Execute a single command on remote side
- Warning
- Method to override
- Returns
- string The text data of response.
Returns an array of debug buffer if debug
property is not FALSE.
- Returns
- array An array of debug buffer.
Returns an array of all errors stored in error buffer.
- Returns
- array An array of error buffer.
Returns data of the last error
- Returns
- array An array of error data (text message, code, target, ...)
isAlive |
( |
|
$timeout = null | ) |
|
Checks if a connection is available
- Parameters
-
int | $timeout | (Option) Timeout in seconds to wait the response from remote side. |
- Returns
- boolean TRUE - connection is available.
FALSE - connection is not available.
Open new connection to remote host
- Parameters
-
array | string | $config | An array of properties to initialize the class. If $config is a string it will be interpreted as a host (same as $config = [ 'host' => $config ]). |
- Returns
- resource|false Resource ID of the open socket or FALSE on fail.
prepareCommand |
( |
|
$command | ) |
|
|
protected |
Extract a single commands from a string
- Parameters
-
string | $command | A string with commands separated by "\n" |
- Returns
- array An array of commands
mixed Defines a debug messages destination.
Possible values:
false - no debug;
1 - debug to buffer;
2 - debug to STDIN;
filename - debug to file;
mixed Defines a error mesages destination.
Possible values:
false - no debug;
1 - debug to buffer;
2 - debug to STDIN;
filename - debug to file;
boolean Defines the method of error throwing.
Possible values:
true - log error to own buffer (no exception), the returned value of fail exec
will be === false;
false - throw exeption on error;
string The target host (name|ip-address)
string The password for authentication.
int The socket default timeout in seconds. Defines how long should wait the response from remote side.
string The username for authentication.
The documentation for this class was generated from the following file: