Package dev.galasa.ipnetwork.spi
Class SSHClient
java.lang.Object
dev.galasa.ipnetwork.spi.SSHClient
- All Implemented Interfaces:
ICommandShell
SSH client for Galasa
-
Constructor Summary
ConstructorDescriptionSSHClient
(String hostname, int port, ICredentials credentials, long defaultTimeoutInMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
void
Disconnect the clientissueCommand
(String command) Issue a command using SSH.issueCommand
(String command, boolean newShell) Issue a command using SSH.issueCommand
(String command, boolean newShell, long timeoutInMillis) Issue a command using SSHissueCommand
(String command, long timeoutInMillis) Issue a command using SSH.issueCommandToShell
(String command) Issue a command using SSH shell.issueCommandToShell
(String command, boolean newShell) Issue a command using SSH shell.issueCommandToShell
(String command, boolean newShell, long timeoutInMillis) Issue a command using SSH shellissueCommandToShell
(String command, long timeoutInMillis) Issue a command using SSH shell.void
reportResultStrings
(boolean report) Ask the shell to log the result strings for all shell commandsvoid
void
setChangePromptCommand
(String command) Define the right command used to change the shell promptvoid
setRemoveAnsiEscapeCodes
(boolean remoteAnsiEscapeCodes) Instruct the command shell to remove ANSI escape codes from the output of commands to the shell
-
Constructor Details
-
SSHClient
public SSHClient(String hostname, int port, ICredentials credentials, long defaultTimeoutInMillis) throws SSHException - Throws:
SSHException
-
-
Method Details
-
issueCommand
Issue a command using SSH. Equivalent toissueCommand(String, boolean, long)
- Specified by:
issueCommand
in interfaceICommandShell
- Parameters:
command
- - command to issue- Returns:
- the output of the command (stdout and stderr)
- Throws:
SSHException
-
issueCommand
Issue a command using SSH. Equivalent toissueCommand(String, boolean, long)
- Specified by:
issueCommand
in interfaceICommandShell
- Parameters:
command
- - command to issuetimeoutInMillis
- - time (in milliseconds) to wait with no new output appearing before timing out- Returns:
- the output of the command (stdout and stderr)
- Throws:
SSHException
-
issueCommand
Issue a command using SSH. Equivalent toissueCommand(String, boolean, long)
- Specified by:
issueCommand
in interfaceICommandShell
- Parameters:
command
- - command to issuenewShell
- - if true will start a new- Returns:
- the output of the command (stdout and stderr)
- Throws:
SSHException
-
issueCommand
public String issueCommand(String command, boolean newShell, long timeoutInMillis) throws SSHException Issue a command using SSH- Specified by:
issueCommand
in interfaceICommandShell
- Parameters:
command
- - command to issuenewShell
- - if true will start a newtimeoutInMillis
- - time (in milliseconds) to wait with no new output appearing before timing out- Returns:
- the output of the command (stdout and stderr)
- Throws:
SSHException
-
setChangePromptCommand
Define the right command used to change the shell prompt- Specified by:
setChangePromptCommand
in interfaceICommandShell
-
issueCommandToShell
Issue a command using SSH shell. Equivalent toissueCommandToShell(String, boolean, long)
- Specified by:
issueCommandToShell
in interfaceICommandShell
- Parameters:
command
- - command to issue- Returns:
- the output of the command
- Throws:
SSHException
-
issueCommandToShell
Issue a command using SSH shell. Equivalent toissueCommandToShell(String, boolean, long)
- Specified by:
issueCommandToShell
in interfaceICommandShell
- Parameters:
command
- - command to issuetimeoutInMillis
- - time (in milliseconds) to wait with no new output appearing before timing out- Returns:
- the output of the command
- Throws:
SSHException
-
issueCommandToShell
Issue a command using SSH shell. Equivalent toissueCommandToShell(String, boolean, long)
- Specified by:
issueCommandToShell
in interfaceICommandShell
- Parameters:
command
- - command to issuenewShell
- - if true will start a new- Returns:
- the output of the command
- Throws:
SSHException
-
issueCommandToShell
public String issueCommandToShell(String command, boolean newShell, long timeoutInMillis) throws SSHException Issue a command using SSH shell- Specified by:
issueCommandToShell
in interfaceICommandShell
- Parameters:
command
- - command to issuenewShell
- - if true will start a newtimeoutInMillis
- - time (in milliseconds) to wait with no new output appearing before timing out- Returns:
- the output of the command
- Throws:
SSHException
-
connect
- Specified by:
connect
in interfaceICommandShell
- Throws:
SSHException
-
restartShell
- Specified by:
restartShell
in interfaceICommandShell
- Throws:
SSHException
-
disconnect
Disconnect the client- Specified by:
disconnect
in interfaceICommandShell
- Throws:
IOException
SSHException
-
reportResultStrings
public void reportResultStrings(boolean report) Description copied from interface:ICommandShell
Ask the shell to log the result strings for all shell commands- Specified by:
reportResultStrings
in interfaceICommandShell
- Parameters:
report
- whether the shell should log the results of the shell commands
-
setRemoveAnsiEscapeCodes
public void setRemoveAnsiEscapeCodes(boolean remoteAnsiEscapeCodes) Description copied from interface:ICommandShell
Instruct the command shell to remove ANSI escape codes from the output of commands to the shell- Specified by:
setRemoveAnsiEscapeCodes
in interfaceICommandShell
-