Introduction

The ATS SSH client allows you to execute remote commands over the SSH protocol



Simple example

Here is a basic example of how you can create a SSH client and execute a command.

After its completion, you can get the exit code and the output to evaluate the command result.

import com.axway.ats.action.ssh.SshClient;

// make an instance of the SSH client by specifying host and user credentials
SshClient sshClient = new SshClient( SERVER_IP, USER_NAME, USER_PASSWORD );

// execute some SSH command
sshClient.execute( <SOME COMMAND> );

// check the command result using the following methods
int exitCode = sshClient.getCommandExitCode();

String standardOutput = sshClient.getStandardOutput();

String errorOutput = sshClient.getErrorOutput();

// disconnect the SSH connection
sshClient.close();

If you have the ATS Agent running on the target host, then it is much better to use the ProcessExecutor (link) instead of the SSH Client.

It performs better and you have more options on setting the command and analyzing the command result.



Back to parent page

Go to Table of Contents