public class SshTask
extends java.lang.Object
implements java.io.Serializable
null
value in cases where you are not waiting for SSH server data but want the
command to be executed immediately.Modifier and Type | Class and Description |
---|---|
static interface |
SshTask.Listener |
Modifier and Type | Field and Description |
---|---|
static int |
ACTIVE
SshTask is active and waiting for start prompt to execute command
|
static int |
COMPLETE
SshTask has finished execution of command and has received end prompt
|
static int |
PENDING
SshTask is waiting to be activated
|
static int |
RUNNING
SshTask has received start prompt and is currently executing command
|
Constructor and Description |
---|
SshTask(java.lang.String name,
java.lang.String promptPattern,
boolean promptPatternIsRegex,
java.lang.String command,
java.lang.String responsePattern,
boolean responsePatternIsRegex) |
SshTask(java.lang.String name,
java.lang.String promptPattern,
boolean promptPatternIsRegex,
java.lang.String command,
java.lang.String responsePattern,
boolean responsePatternIsRegex,
int regexMatchLength,
java.lang.String endOfLine,
java.lang.String characterSet,
long promptTimeout,
long responseTimeout) |
SshTask(java.lang.String promptPattern,
java.lang.String command,
java.lang.String responsePattern)
Constructs a new
SshTask instance. |
SshTask(java.lang.String name,
java.lang.String promptPattern,
java.lang.String command,
java.lang.String responsePattern)
Constructs a new
SshTask instance. |
Modifier and Type | Method and Description |
---|---|
void |
activate(SshTask.Listener listener,
java.io.OutputStream out,
java.lang.String previousTaskResponse,
java.lang.String endOfLine) |
void |
cancel()
Cancels this task and subsequent tasks by setting it's status to complete.
|
java.lang.String |
getCharacterSet()
Gets the character set
|
java.lang.String |
getCommand()
Gets the command to execute
|
boolean |
getDebug()
Checks whether debugging is enabled for this task.
|
java.io.PrintStream |
getDebugStream()
Gets debug stream used when printing debug messages.
|
java.lang.String |
getEndPrompt()
Gets the end shell prompt this
SshTask should wait for to indicate that this SshTask is complete. |
long |
getEndPromptTimeout()
Gets the maximum timeout between the time the task is in running state and the expected end prompt is received.
|
java.lang.Exception |
getError() |
java.lang.String |
getName()
Gets name of this
SshTask as defined in constructor. |
int |
getRegexMatchLength()
Gets the number of characters to read from the end of the response buffer when using regular expressions
to detect start or end prompts.
|
java.lang.String |
getResponse()
Gets response to command executed.
|
java.lang.String |
getStartPrompt()
Gets the shell prompt this
SshTask should wait for before executing command. |
long |
getStartPromptTimeout()
Gets the maximum timeout between the time the task is in active state and the expected start prompt is received.
|
int |
getStatus()
Gets completion status of this
SshTask . |
java.lang.String |
getStatusString(int status)
Gets status string based on task status
|
java.lang.String |
getTerminator()
Gets line terminator used when sending commands.
|
boolean |
isActive()
Checks if this
SshTask is active. |
boolean |
isComplete()
Checks if this
SshTask is complete. |
boolean |
isEndPromptRegex()
Checks if end prompt is a regular expression
|
boolean |
isPending()
Checks if this
SshTask is pending activation. |
boolean |
isRunning()
Checks if this
SshTask is running. |
boolean |
isStartPromptRegex()
Specified if start prompt is a regular expression
|
boolean |
isTimedOut()
Checks if task has exceeded timeout
|
void |
onData(char data) |
void |
onEof() |
void |
setCharacterSet(java.lang.String value)
Sets character set used when write data
|
void |
setDebug(boolean value)
Enables/disables additional debugging for this task.
|
void |
setDebugStream(java.io.PrintStream value)
Sets debug stream to be used when printing debug messages.
|
void |
setEndPromptRegex(boolean value)
Specifies if end prompt is a regular expression
|
void |
setEndPromptTimeout(long value)
Sets the maximum timeout between the time the task is in running state and the expected end prompt is received.
|
void |
setRegexMatchLength(int value)
Sets the number of characters to read from the end of the response buffer when using regular expressions
to detect start or end prompts.
|
void |
setStartPromptRegex(boolean value)
Specifies if start prompt is a regular expression
|
void |
setStartPromptTimeout(long value)
Sets the maximum timeout between the time the task is in active state and the expected start prompt is received.
|
void |
setTerminator(java.lang.String value)
Sets line terminator used when sending commands.
|
public static final int PENDING
public static final int ACTIVE
public static final int RUNNING
public static final int COMPLETE
public SshTask(java.lang.String name, java.lang.String promptPattern, boolean promptPatternIsRegex, java.lang.String command, java.lang.String responsePattern, boolean responsePatternIsRegex, int regexMatchLength, java.lang.String endOfLine, java.lang.String characterSet, long promptTimeout, long responseTimeout)
public SshTask(java.lang.String name, java.lang.String promptPattern, boolean promptPatternIsRegex, java.lang.String command, java.lang.String responsePattern, boolean responsePatternIsRegex)
public SshTask(java.lang.String name, java.lang.String promptPattern, java.lang.String command, java.lang.String responsePattern)
SshTask
instance.name
- a name to uniquely identify this SshTask
.promptPattern
- the shell prompt this task should wait for before executing command.command
- the command to executeresponsePattern
- the end shell prompt this task should wait for to indicate that this task is finished.public SshTask(java.lang.String promptPattern, java.lang.String command, java.lang.String responsePattern)
SshTask
instance.promptPattern
- the start data this task should wait for before executing command.command
- the command to executeresponsePattern
- the end data this task should wait for to indicate that this task is finished.public java.lang.String getName()
SshTask
as defined in constructor.SshTask
, Unknown
if not defined.public java.lang.String getStartPrompt()
SshTask
should wait for before executing command.public boolean isStartPromptRegex()
public void setStartPromptRegex(boolean value)
value
- true if start prompt is a regular expression, false otherwiseSshException
- if the start prompt is an invalid regular expressionsetRegexMatchLength(int)
public java.lang.String getCommand()
public java.lang.String getEndPrompt()
SshTask
should wait for to indicate that this SshTask
is complete.public boolean isEndPromptRegex()
public void setEndPromptRegex(boolean value)
value
- true if end prompt is a regular expression, false otherwiseSshException
- if the end prompt is an invalid regular expressionsetRegexMatchLength(int)
public int getRegexMatchLength()
public void setRegexMatchLength(int value)
value
- public java.lang.String getTerminator()
public void setTerminator(java.lang.String value)
value
- line terminatorpublic void setCharacterSet(java.lang.String value)
value
- the character setpublic java.lang.String getCharacterSet()
public long getStartPromptTimeout()
public void setStartPromptTimeout(long value)
value
- the timeout in millisecondspublic long getEndPromptTimeout()
public void setEndPromptTimeout(long value)
value
- the timeout in millisecondspublic boolean getDebug()
public void setDebug(boolean value)
value
- true if debugging is enabled, false otherwisepublic void setDebugStream(java.io.PrintStream value)
value
- a PrintStreampublic java.io.PrintStream getDebugStream()
public int getStatus()
SshTask
.public java.lang.String getStatusString(int status)
public boolean isPending()
SshTask
is pending activation.true
if pending activation, false
otherwisepublic boolean isActive()
SshTask
is active.true
if active, false
otherwisepublic boolean isRunning()
SshTask
is running.true
if running, false
otherwisepublic boolean isComplete()
SshTask
is complete.true
if complete, false
otherwisepublic java.lang.String getResponse()
isComplete()
public boolean isTimedOut()
public java.lang.Exception getError()
public void activate(SshTask.Listener listener, java.io.OutputStream out, java.lang.String previousTaskResponse, java.lang.String endOfLine)
public void onData(char data)
public void onEof()
public void cancel()
Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved