The SSHSession class is the main class for SSH session management.

The SSHSession class defines the following constructors.

Constructor

Description

SSHSession(string,string):SSHSession

Creates a new SSHSession.

SSHSession(string,string,number):SSHSession

Creates a new SSHSession.

The SSHSession class defines the following attributes.

Attribute

Returns

Description

cmd

String

Command to run

error

String

Command error, if any

Note

The error message depends on your operating system. The operating system returns a string from the error messages buffer.

exitCode

Number

Exit code of the last command

Note

The exit code depends on your operating system. Refer to your operating system's documentation for descriptions.

output

String

Command output, if any

pty

Boolean

Requesting a pseudo-terminal

state

String

Run state

terminal

String

Terminal type

The SSHSession class defines the following methods.

Method

Returns

Description

addEnvironment(string,string):Object

Object

Fills a property list of environment variables that are set prior to opening a channel.

connectWithIdentity(Path,SecureString):Object

Object

Connects the session using public key authentication.

connectWithPassword(SecureString):Object

Object

Connects the session using simple password authentication.

connectWithPasswordOrIdentity (boolean,SecureString,Path):Object

Object

Connects the session using either password or public key authentication.

disconnect():Object

Object

Disconnects the current session.

execute():Object

Object

Runs a single command and returns immediately. Leaves an open session. You can disconnect the session manually.

executeAndLog(string):Object

Object

Runs a single command and waits until it is completed.

executeCommand(string,boolean):string

String

Runs a single command, waits until it is completed, and returns the stdout result, if synchronous. Leaves an open session. You can disconnect the session manually.

findAll(Path,string):string[]

Array of String

Searches recursively and returns files and directories that match a pattern. Leaves an open session. You can disconnect the session manually.

findDir(Path,string):string[]

Array of String

Searches recursively and returns directories that match a pattern. Leaves an open session. You can disconnect the session manually.

findFile(Path,string):string[]

Array of String

Searches recursively and returns files that match a pattern. Leaves an open session. You can disconnect the session manually.

getFile(Path,Path):number

Number

Copies a file from a remote host to the Orchestrator server. Leaves an open session. You can disconnect the session manually. Returns 0 if successful, -1 if an error has occured, and -2 if a fatal error has occured.

listAll(Path):string[]

Array of String

Lists files and directories in a path. Leaves an open session. You can disconnect the session manually.

listDir(Path):string[]

Array of String

Lists directories in a path. Leaves an open session. You can disconnect the session manually.

listFile(Path):string[]

Array of String

Lists files in a path. Leaves an open session. You can disconnect the session manually.

putFile(Path,Path):number

Number

Copies a file from the Orchestrator server to a remote host. The destination directory must exist. Returns 0 if successful, or -1 if an error has occured.