Cradle
0.3.3
Simple library for creating Web-based applications
|
Public Member Functions | |
open ($config=null) | |
close () | |
getInputPrompt () | |
getInputBuffer ($trimmed=null) | |
getLastTimeout () | |
getBanner () | |
![]() | |
__construct ($config=null) | |
__destruct () | |
open ($config=null) | |
close () | |
exec ($command, $timeout=null) | |
getLastError () | |
getErrors () | |
getDebug () | |
clearBuffers ($type= 'all') | |
isAlive ($timeout=null) | |
Data Fields | |
const | ERR_SOCKET = 5 |
const | ERR_CLOSED_BY_REMOTE = 6 |
const | ERR_TIMEOUT = 7 |
const | ERR_TIMEOUT_EXEC = 8 |
$port = 23 | |
$timeout = 10 | |
$trimResponse = true | |
$terminalEchoOn = false | |
$terminalGoAhead = true | |
$ternimalType = "DEC-VT100" | |
$terminalWidth = 0 | |
$terminatHeight = 0 | |
$inputPromptTemplate = '/^[^#>\$\%]+[#>\$\%]\s*$/' | |
![]() | |
const | ERR_HOST_IS_EMPTY = 1 |
const | ERR_UNABLE_TO_CONNECT = 2 |
const | ERR_AUTH_FAIL = 3 |
$host | |
$port | |
$user | |
$password | |
$timeout | |
$errorSilent = true | |
$debug = 1 | |
$error = 1 | |
Protected Member Functions | |
error ($code, $source="", $detail=null) | |
debug ($message, $source="") | |
handshake () | |
authenticate () | |
executeCommand ($command, $timeout=null) | |
trimResponse ($responseData) | |
send ($data) | |
read ($timeout) | |
getAnswer ($inputPromptTemplates, $analyzeMode=0, $timeout=null, $callbackFunctions=null, $failFunction=null) | |
parseInput ($string) | |
getCommResponse ($commBuffer) | |
toString ($input, $mode=null) | |
getTerminalCommandName ($code) | |
getTerminalOptionName ($code) | |
![]() | |
init ($config) | |
error ($code, $source="", $message=null, $detail=null) | |
debug ($message, $source="") | |
connect () | |
authenticate () | |
prepareCommand ($command) | |
executeCommand ($command, $timeout=null) | |
Protected Attributes | |
$socket | |
$isAuthenticated = false | |
$banner | |
$inputBuffer | |
$inputPrompt | |
$lastRequest | |
$lastTimeout | |
$tmCmd | |
$tmCmdCodes = null | |
$tmOption | |
$tmOptionCodes = null | |
![]() | |
$connection | |
$isAuthenticated = false | |
$debugLogger | |
$errorLogger | |
Telnet interaction.
A simple class to send commands to remote host through the TELNET protocol.
TELNET protocol specification: http://tools.ietf.org/html/rfc854
TELNET option: http://www.iana.org/assignments/telnet-options/telnet-options.xhtml
TELNET terminals: http://www.iana.org/assignments/terminal-type-names/terminal-type-names.xhtml#terminal-type-names-1
|
protected |
Authenticate the access to remote side
close | ( | ) |
Close the telnet connection
|
protected |
Create a debug message
|
protected |
Create an error
Exception |
|
protected |
Execute a single command on remote side
|
protected |
Advanced read
(read
wrapper)
getBanner | ( | ) |
Returns a banner of remote side
|
protected |
Create a string with TELNET commands for response to remote side
getInputBuffer | ( | $trimmed = null | ) |
Returns the last received data from remote side
boolean | $trimmed | (option) Default value = $trimResponse ( |
getInputPrompt | ( | ) |
Returns a input prompt marker of remote side
getLastTimeout | ( | ) |
Returns seconds of the last timeout
|
protected |
TELNET command code to command name
|
protected |
TELNET option code to option name
|
protected |
First request to remote side
open | ( | $config = null | ) |
Open new telnet connection
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 ]). |
|
protected |
Parses data and separate into TELNET-commands and text
|
protected |
Reads the response data from the socket. Parses response data and separates into commands and text data. Sends telnet commands to remote side if it will found in response.
int | $timeout | Maximum seconds to wait the response |
Exception |
|
|
protected |
Sends a data through the socket
string | $data | Data to send |
|
protected |
Converts mixed data to string
|
protected |
Strip a garbage from response data
string | $responseData | Response data |
$inputPromptTemplate = '/^[^#>\$\%]+[#>\$\%]\s*$/' |
string Regular expression template to find a input prompt marker ('Ready for input') of remote side. By default it set as: '/^[^#>$%]+[#>$%]*$/'
$port = 23 |
int The target TCP port.
$terminalEchoOn = false |
boolean Enable or disable echo.
TELNET option (1) "ECHO-ON" http://tools.ietf.org/html/rfc857
$terminalGoAhead = true |
boolean Enable or disable suppressing transmission of the 'TELNET GO AHEAD' character.
TELNET option (3) "SUPPRESS-GO-AHEAD" http://tools.ietf.org/html/rfc858
$terminalWidth = 0 |
int Value of terminal characters in line.
TELNET option (31) "WINDOW-SIZE" http://tools.ietf.org/html/rfc1073
$terminatHeight = 0 |
int Value of terminal lines count.
TELNET option (31) "WINDOW-SIZE" http://tools.ietf.org/html/rfc1073
$ternimalType = "DEC-VT100" |
string Terminal type name.
TELNET option (24) "TERMINAL-TYPE" http://tools.ietf.org/html/rfc1091
TELNET terminal names http://www.iana.org/assignments/terminal-type-names/terminal-type-names.xhtml#terminal-type-names-1
$timeout = 10 |
int The socket default timeout in seconds. Defines how long should wait the response from remote side.
|
protected |
array TELNET commands
|
protected |
array TELNET options
$trimResponse = true |
boolean If set true, the data returned by exec
method will be trimmed. The echo of the command will be deleted from the beginning and the marker 'Ready for input' of the remote side will be deleted from the end.