|
SSH Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.telnet.TelnetAdapter
com.jscape.inet.telnet.TelnetTask
public class TelnetTask
The TelnetTask class represents a command to be executed in batch (non-interactive) mode. In order to execute a command in batch mode the TelnetTask must know the following:
Start Prompt - The start prompt is the data that is sent back by the Telnet server indicating that it is ready to execute the command. e.g. user@localhost$ 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 Telnet server indicating that it has completed execution of the command. In most cases this is the same as the Start Prompt. e.g. user@localhost$ When creating a new TelnetTask 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 anull
value in cases where you are not waiting for Telnet server data but want the
command to be executed immediately.
Field Summary | |
---|---|
static int |
ACTIVE
TelnetTask is active and waiting for start prompt to execute command |
static int |
COMPLETE
TelnetTask has finished execution of command and has received end prompt |
static int |
PENDING
TelnetTask is waiting to be activated |
static int |
RUNNING
TelnetTask has received start prompt and is currently executing command |
Constructor Summary | |
---|---|
TelnetTask(java.lang.String startPrompt,
java.lang.String command,
java.lang.String endPrompt)
Constructs a new TelnetTask instance. |
|
TelnetTask(java.lang.String name,
java.lang.String startPrompt,
java.lang.String command,
java.lang.String endPrompt)
Constructs a new TelnetTask instance. |
Method Summary | |
---|---|
void |
cancel()
Cancels this task and subsequent tasks by setting it's status to complete. |
void |
dataReceived(TelnetDataReceivedEvent event)
Gets data received from Telnet server as fired by TelnetListener |
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 TelnetTask should wait for to indicate that this TelnetTask 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 TelnetTask as defined in constructor. |
TelnetTask |
getNextTask()
Gets the next task executed after this TelnetTask . |
TelnetTask |
getPreviousTask()
Gets the TelnetTask executed prior to this TelnetTask . |
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. |
TelnetScript |
getScript()
Gets the TelnetScript this TelnetTask is bound to. |
java.lang.String |
getStartPrompt()
Gets the shell prompt this TelnetTask 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 TelnetTask . |
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 TelnetTask is active. |
boolean |
isComplete()
Checks if this TelnetTask is complete. |
boolean |
isEndPromptRegex()
Checks if end prompt is a regular expression |
boolean |
isPending()
Checks if this TelnetTask is pending activation. |
boolean |
isRunning()
Checks if this TelnetTask is running. |
boolean |
isStartPromptRegex()
Specified if start prompt is a regular expression |
boolean |
isTimedOut()
Checks if task has exceeded timeout |
void |
setDebug(boolean debug)
Enables/disables additional debugging for this task. |
void |
setDebugStream(java.io.PrintStream debugStream)
Sets debug stream to be used when printing debug messages. |
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 |
setRegexMatchLength(int regexMatchLength)
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 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. |
Methods inherited from class com.jscape.inet.telnet.TelnetAdapter |
---|
connected, disconnected, dontOption, doOption, doSubOption, willOption, wontOption |
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 TelnetTask(java.lang.String name, java.lang.String startPrompt, java.lang.String command, java.lang.String endPrompt)
TelnetTask
instance.
name
- a name to uniquely identify this TelnetTask
.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 TelnetTask(java.lang.String startPrompt, java.lang.String command, java.lang.String endPrompt)
TelnetTask
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 TelnetTask getNextTask()
TelnetTask
.
TelnetTask
or null
if none foundpublic TelnetTask getPreviousTask()
TelnetTask
executed prior to this TelnetTask
.
TelnetTask
or null
if no previous TelnetTask
foundpublic TelnetScript getScript()
TelnetScript
this TelnetTask
is bound to.
TelnetScript
TelnetScript
public void setDebug(boolean debug)
debug
- true if debugging is enabled, false otherwisepublic void setDebugStream(java.io.PrintStream debugStream)
debugStream
- a PrintStreampublic java.io.PrintStream getDebugStream()
public boolean getDebug()
public void dataReceived(TelnetDataReceivedEvent event)
TelnetListener
dataReceived
in interface TelnetListener
dataReceived
in class TelnetAdapter
event
- a TelnetDataReceivedEvent
TelnetDataReceivedEvent
,
TelnetListener
public java.lang.String getCommand()
public java.lang.String getStartPrompt()
TelnetTask
should wait for before executing command.
public java.lang.String getEndPrompt()
TelnetTask
should wait for to indicate that this TelnetTask
is complete.
public int getStatus()
TelnetTask
.
TelnetTask
PENDING
,
ACTIVE
,
RUNNING
,
COMPLETE
public java.lang.String getResponse()
isComplete()
public java.lang.String getStatusString(int status)
status
- the status code
PENDING
,
ACTIVE
,
RUNNING
,
COMPLETE
public boolean isPending()
TelnetTask
is pending activation.
true
if pending activation, false
otherwisepublic boolean isActive()
TelnetTask
is active.
true
if active, false
otherwisepublic boolean isRunning()
TelnetTask
is running.
true
if running, false
otherwisepublic boolean isComplete()
TelnetTask
is complete.
true
if complete, false
otherwisepublic java.lang.String getName()
TelnetTask
as defined in constructor.
TelnetTask
, null
if not defined.public java.lang.String getTerminator()
public void setTerminator(java.lang.String string)
string
- line terminatorpublic void cancel()
public long getEndPromptTimeout()
public long getStartPromptTimeout()
public void setEndPromptTimeout(long endPromptTimeout)
endPromptTimeout
- the timeout in millisecondspublic void setStartPromptTimeout(long startPromptTimeout)
startPromptTimeout
- the timeout in millisecondspublic void setRegexMatchLength(int regexMatchLength)
regexMatchLength
- public int getRegexMatchLength()
public boolean isTimedOut()
public boolean isEndPromptRegex()
public boolean isStartPromptRegex()
public void setEndPromptRegex(boolean b) throws TelnetException
b
- true if end prompt is a regular expression, false otherwise
TelnetException
- if the end prompt is an invalid regular expressionsetRegexMatchLength(int)
public void setStartPromptRegex(boolean b) throws TelnetException
b
- true if start prompt is a regular expression, false otherwise
TelnetException
- if the start prompt is an invalid regular expressionsetRegexMatchLength(int)
|
SSH Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |