|
SSH Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.telnet.TelnetScript
public class TelnetScript
The TelnetScript class provides a simple way of running a set of batch scripted commands against a TelnetServer. When communicating with a Telnet server in interactive mode (non-batch) the user must wait until the completion of the previous command before entering a new command. In interactive mode the completion of the previous command is generally indicated by the display of the shell prompt which allows the user to enter the next command. The TelnetScript class is especially useful in automating Telnet procedures such as user login and command execution.
Example Usage:
// create new Telnet instance Telnet telnet = new Telnet("10.0.0.1"); // create new TelnetScript instance TelnetScript script = new TelnetScript(telnet); // create task to automatically submit username TelnetTask username = new TelnetTask("login:","jsmith","Password:"); // create task to automatically submit password TelnetTask password = new TelnetTask("Password:","secret","$"); // create task to perform a directory listing TelnetTask dirListing = new TelnetTask("$","ls -al","$"); // add tasks to script script.addTask(username); script.addTask(password); script.addTask(dirListing); // connect to Telnet server and execute TelnetScript telnet.connect(); // disconnect from Telnet server telnet.disconnect();
Constructor Summary | |
---|---|
TelnetScript(Telnet telnet)
Constructs a new TelnetScript instance. |
|
TelnetScript(Telnet telnet,
java.lang.String terminator)
Constructs a new TelnetScript instance. |
Method Summary | |
---|---|
void |
addTask(TelnetTask task)
Adds a TelnetTask to this TelnetScript. |
void |
addTelnetScriptListener(TelnetScriptListener listener)
Adds a TelnetScriptListener to this TelnetScript . |
void |
clear()
Clears all tasks from the script. |
TelnetTask |
getTask(java.lang.String name)
Gets the named TelnetTask based on the name attribute of a TelnetTask. |
boolean |
isComplete()
Checks whether this TelnetScript has completed execution of all TelnetTask. |
boolean |
isEmpty()
Checks if there are any TelnetTask bound to this TelnetScript |
void |
removeTelnetScriptListener(TelnetScriptListener listener)
Removes a TelnetScriptListener from this TelnetScript |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TelnetScript(Telnet telnet)
telnet
- Telnet instance this TelnetScript is bound to.Telnet
public TelnetScript(Telnet telnet, java.lang.String terminator)
telnet
- Telnet instance this TelnetScript is bound to.terminator
- the line terminator to use when executing command for a TelnetTaskTelnet
,
TelnetTask
,
addTask(com.jscape.inet.telnet.TelnetTask)
Method Detail |
---|
public boolean isEmpty()
public void clear()
public void addTask(TelnetTask task)
task
- the TelnetTask to addTelnetTask
public TelnetTask getTask(java.lang.String name)
name
- the name of the TelnetTask to retrieve.
TelnetTask
public void addTelnetScriptListener(TelnetScriptListener listener)
TelnetScriptListener
to this TelnetScript
.
listener
- the TelnetScriptListener
instance to addTelnetScriptListener
public void removeTelnetScriptListener(TelnetScriptListener listener)
TelnetScriptListener
from this TelnetScript
listener
- the TelnetScriptListener
instance to removeTelnetScriptListener
public boolean isComplete()
|
SSH Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |