|
SSH Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jscape.inet.ssh.SshAdapter
com.jscape.inet.ssh.SshTask
The SshTask class represents a command to be executed in batch (non-interactive) mode on SSH server. In order to execute a command in batch mode the SshTask must know the following:
Start Prompt - The start prompt is the data that is sent back by the SSH server indicating that it is ready to execute the command. e.g. $
Command - The command is the command to be executed. e.g. ls -al
End Prompt - The end prompt is the data that is sent back by the SSH server indicating that it has completed execution of the command. In most cases this is the same as the Start Prompt. e.g. $
When creating a new SshTask you must at a MINIMUM provide both the Command and End Prompt. In most cases a Start Prompt should be
provided although you may provide a null value in cases where you are not waiting for SSH server data but want the
command to be executed immediately.
| Field Summary | |
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 Summary | |
SshTask(java.lang.String startPrompt,
java.lang.String command,
java.lang.String endPrompt)
Constructs a new SshTask instance. |
|
SshTask(java.lang.String name,
java.lang.String startPrompt,
java.lang.String command,
java.lang.String endPrompt)
Constructs a new SshTask instance. |
|
| Method Summary | |
void |
cancel()
Cancels this task by setting it's status to complete. |
void |
dataReceived(SshDataReceivedEvent event)
Gets data received from Ssh server as fired by SshListener |
java.lang.String |
getCommand()
Gets the command to execute |
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.String |
getName()
Gets name of this SshTask as defined in constructor. |
SshTask |
getNextTask()
Gets the next task executed after this SshTask. |
SshTask |
getPreviousTask()
Gets the SshTask executed prior to this SshTask. |
java.lang.String |
getResponse()
Gets response to command executed. |
SshScript |
getScript()
Gets the SshScript this SshTask is bound to. |
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 |
getTerminator()
Gets line terminator used when sending commands. |
long |
getTimeout()
Deprecated. replaced by getEndPromptTimeout |
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 |
setEndPromptRegex(boolean b)
Specifies if end prompt is a regular expression |
void |
setEndPromptTimeout(long endPromptTimeout)
Sets the maximum timeout between the time the task is in running state and the expected end prompt is received. |
void |
setStartPromptRegex(boolean b)
Specifies if start prompt is a regular expression |
void |
setStartPromptTimeout(long startPromptTimeout)
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 string)
Sets line terminator used when sending commands. |
void |
setTimeout(long timeout)
Deprecated. replaced by setEndPromptTimeout |
| Methods inherited from class com.jscape.inet.ssh.SshAdapter |
connected, disconnected |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int PENDING
public static final int ACTIVE
public static final int RUNNING
public static final int COMPLETE
| Constructor Detail |
public SshTask(java.lang.String name,
java.lang.String startPrompt,
java.lang.String command,
java.lang.String endPrompt)
SshTask instance.
name - a name to uniquely identify this SshTask.startPrompt - the shell prompt this task should wait for before executing command.command - the command to executeendPrompt - the end shell prompt this task should wait for to indicate that this task is finished.
public SshTask(java.lang.String startPrompt,
java.lang.String command,
java.lang.String endPrompt)
SshTask instance.
startPrompt - the start data this task should wait for before executing command.command - the command to executeendPrompt - the end data this task should wait for to indicate that this task is finished.| Method Detail |
public SshTask getNextTask()
SshTask.
SshTask or null if none foundpublic SshTask getPreviousTask()
SshTask executed prior to this SshTask.
SshTask or null if no previous SshTask foundpublic SshScript getScript()
SshScript this SshTask is bound to.
SshScriptSshScriptpublic void dataReceived(SshDataReceivedEvent event)
SshListener
dataReceived in interface SshListenerdataReceived in class SshAdapterevent - a SshDataReceivedEventSshDataReceivedEvent,
SshListenerpublic void cancel()
public java.lang.String getCommand()
public java.lang.String getStartPrompt()
SshTask should wait for before executing command.
public java.lang.String getEndPrompt()
SshTask should wait for to indicate that this SshTask is complete.
public int getStatus()
SshTask.
SshTaskPENDING,
ACTIVE,
RUNNING,
COMPLETEpublic java.lang.String getResponse()
isComplete()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 getName()
SshTask as defined in constructor.
SshTask, null if not defined.public java.lang.String getTerminator()
public void setTerminator(java.lang.String string)
string - line terminatorpublic long getTimeout()
getEndPromptTimeout()public long getEndPromptTimeout()
public long getStartPromptTimeout()
public void setTimeout(long timeout)
timeout - the task timeoutsetEndPromptTimeout(long)public void setEndPromptTimeout(long endPromptTimeout)
endPromptTimeout - the timeout in millisecondspublic void setStartPromptTimeout(long startPromptTimeout)
startPromptTimeout - the timeout in millisecondspublic boolean isEndPromptRegex()
public boolean isStartPromptRegex()
public void setEndPromptRegex(boolean b)
throws SshException
b - true if end prompt is a regular expression, false otherwise
SshException - if the end prompt is an invalid regular expression
public void setStartPromptRegex(boolean b)
throws SshException
b - true if start prompt is a regular expression, false otherwise
SshException - if the start prompt is an invalid regular expressionpublic boolean isTimedOut()
|
SSH Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||