SExec Class

Properties   Methods   Events   Configuration Settings   Errors  

The SExec class is used to remotely execute a command on an SSH server.

Class Name

IPWorksSSH_SExec

Procedural Interface

 ipworksssh_sexec_open();
 ipworksssh_sexec_close($res);
 ipworksssh_sexec_register_callback($res, $id, $function);
 ipworksssh_sexec_get_last_error($res);
 ipworksssh_sexec_get_last_error_code($res);
 ipworksssh_sexec_set($res, $id, $index, $value);
 ipworksssh_sexec_get($res, $id, $index);
 ipworksssh_sexec_do_config($res, $configurationstring);
 ipworksssh_sexec_do_decodepacket($res, $encodedpacket);
 ipworksssh_sexec_do_doevents($res);
 ipworksssh_sexec_do_encodepacket($res, $packet);
 ipworksssh_sexec_do_execute($res, $command);
 ipworksssh_sexec_do_getsshparam($res, $payload, $field);
 ipworksssh_sexec_do_getsshparambytes($res, $payload, $field);
 ipworksssh_sexec_do_interrupt($res);
 ipworksssh_sexec_do_reset($res);
 ipworksssh_sexec_do_send($res, $text);
 ipworksssh_sexec_do_setsshparam($res, $payload, $fieldtype, $fieldvalue);
 ipworksssh_sexec_do_sshlogoff($res);
 ipworksssh_sexec_do_sshlogon($res, $sshhost, $sshport);

Remarks

The SExec class establishes a Secure Shell (SSH) connection to a server and starts up the user's default shell. Using the class is very simple. The destination is specified by the SSHHost property, and the login information is given by the SSHUser and SSHPassword properties. To execute the command, simply call the Execute command or set the Command property with the command you wish to execute as the parameter. Further input can be supplied to the Text parameter of the Send method or via the Stdin property.

The output of the command is returned through the Stdout event. If an error happens on the protocol level, the error message can be found in the ErrorMessage property. Errors during command execution (the stderr stream) are given by the Stderr event. Once the remote command or application terminates, the class will disconnect from the server. If the application's exit status is non-zero (success), the class will throw an exception.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

CommandThe command to be sent to the remote host.
ConnectedTriggers a connection or disconnection.
ErrorMessageThe error message returned by the server along with the ExitStatus .
ExitStatusThe exit code for the last executed command.
FirewallAutoDetectThis property tells the class whether or not to automatically detect and use firewall system settings, if available.
FirewallTypeThis property determines the type of firewall to connect through.
FirewallHostThis property contains the name or IP address of firewall (optional).
FirewallPasswordThis property contains a password if authentication is to be used when connecting through the firewall.
FirewallPortThis property contains the TCP port for the firewall Host .
FirewallUserThis property contains a user name if authentication is to be used connecting through a firewall.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the class binds.
SSHAcceptServerHostKeyEncodedThe certificate (PEM/base64 encoded).
SSHAuthModeThe authentication method to be used the class when calling SSHLogon .
SSHCertEncodedThe certificate (PEM/base64 encoded).
SSHCertStoreThe name of the certificate store for the client certificate.
SSHCertStorePasswordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
SSHCertStoreTypeThe type of certificate store for this certificate.
SSHCertSubjectThe subject of the certificate used for client authentication.
SSHCompressionAlgorithmsA comma-separated list containing all allowable compression algorithms.
SSHEncryptionAlgorithmsA comma-separated list containing all allowable encryption algorithms.
SSHHostThe address of the SSH host.
SSHPasswordThe password for SSH password-based authentication.
SSHPortThe port on the SSH server where the SSH service is running; by default, 22.
SSHUserThe username for SSH authentication.
StdinA string of data to be sent to the remote host while connected.
TimeoutA timeout for the class.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

ConfigSets or retrieves a configuration setting.
DecodePacketDecodes a hex-encoded SSH packet.
DoEventsProcesses events from the internal message queue.
EncodePacketHex encodes an SSH packet.
ExecuteExecute a Command on the remote host.
GetSSHParamUsed to read a field from an SSH packet's payload.
GetSSHParamBytesUsed to read a field from an SSH packet's payload.
InterruptInterrupt the current method.
ResetReset the class.
SendSend standard input to the program executing on the remote host.
SetSSHParamUsed to write a field to the end of a payload.
SSHLogoffLogoff from the SSH server.
SSHLogonLogon to the SSHHost using the current SSHUser and SSHPassword .

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

ConnectedFired immediately after a connection completes (or fails).
ConnectionStatusFired to indicate changes in connection state.
DisconnectedFired when a connection is closed.
ErrorInformation about errors during data delivery.
LogFires once for each log message.
SSHCustomAuthFired when the class is doing custom authentication.
SSHKeyboardInteractiveFired when the class receives a request for user input from the server.
SSHServerAuthenticationFired after the server presents its public key to the client.
SSHStatusShows the progress of the secure connection.
StderrFired when data (complete lines) come in through stderr.
StdoutFired when data (complete lines) come in through stdout.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

DisconnectOnChannelCloseWhether to automatically close the connection when a channel is closed.
EncodedTerminalModesThe terminal mode to set when communicating with the SSH host.
StdInFileThe file to use as Stdin data.
TerminalHeightThe height of the terminal display.
TerminalModesThe terminal mode to set when communicating with the SSH host.
TerminalUsePixelWhether the terminal's dimensions are in columns/rows or pixels.
TerminalWidthThe width of the terminal display.
ClientSSHVersionStringThe SSH version string used by the class.
EnablePageantAuthWhether to use a key stored in Pageant to perform client authentication.
KerberosDelegationIf true, asks for credentials with delegation enabled during authentication.
KerberosRealmThe fully qualified domain name of the Kerberos Realm to use for GSSAPI authentication.
KerberosSPNThe Kerberos Service Principal Name of the SSH host.
KeyRenegotiationThresholdSets the threshold for the SSH Key Renegotiation.
LogLevelSpecifies the level of detail that is logged.
MaxPacketSizeThe maximum packet size of the channel, in bytes.
MaxWindowSizeThe maximum window size allowed for the channel, in bytes.
PasswordPromptThe text of the password prompt used in keyboard-interactive authentication.
PreferredDHGroupBitsThe size (in bits) of the preferred modulus (p) to request from the server.
RecordLengthThe length of received data records.
ServerSSHVersionStringThe remote host's SSH version string.
SignedSSHCertThe CA signed client public key used when authenticating.
SSHAcceptAnyServerHostKeyIf set the class will accept any key presented by the server.
SSHAcceptServerCAKeyThe CA public key that signed the server's host key.
SSHAcceptServerHostKeyFingerPrintThe fingerprint of the server key to accept.
SSHFingerprintHashAlgorithmThe algorithm used to calculate the fingerprint.
SSHFingerprintMD5The server hostkey's MD5 fingerprint.
SSHFingerprintSHA1The server hostkey's SHA1 fingerprint.
SSHFingerprintSHA256The server hostkey's SHA256 fingerprint.
SSHKeepAliveCountMaxThe maximum number of keep alive packets to send without a response.
SSHKeepAliveIntervalThe interval between keep alive packets.
SSHKeyExchangeAlgorithmsSpecifies the supported key exchange algorithms.
SSHKeyRenegotiateCauses the class to renegotiate the SSH keys.
SSHMacAlgorithmsSpecifies the supported Mac algorithms.
SSHPubKeyAuthSigAlgorithmsSpecifies the enabled signature algorithms that may be used when attempting public key authentication.
SSHPublicKeyAlgorithmsSpecifies the supported public key algorithms.
SSHVersionPatternThe pattern used to match the remote host's version string.
TryAllAvailableAuthMethodsIf set to true, the class will try all available authentication methods.
WaitForChannelCloseWhether to wait for channels to be closed before disconnected.
WaitForServerDisconnectWhether to wait for the server to close the connection.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the class whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe port in the local host where the class binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
ProxyExceptionsListA semicolon separated list of hosts and IPs to bypass when using a proxy.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
TcpNoDelayWhether or not to delay when sending packets.
UseIPv6Whether to use IPv6.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2023 /n software inc. - All rights reserved.
IPWorks SSH 2020 PHP Edition - Version 20.0 [Build 8501]