|
SSH Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.ssh.SshScript
public class SshScript
The SshScript class provides a simple way of running a set of batch scripted commands against a SSH server. When communicating with a SSH 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 SshScript class is especially useful in automating SSH procedures such as user login and command execution.
For simple scripting tasks see the SshSession
class.
Example Usage:
// create new Ssh instance Ssh Ssh = new Ssh(hostname,username,password); // create new SshScript instance SshScript script = new SshScript(Ssh); // create task to perform a directory listing SshTask dirListing = new SshTask("$","ls -al","$"); // add task to script script.addTask(dirListing); // connect to SSH server and execute SshScript ssh.connect(); // disconnect from SSH server ssh.disconnect();
SshSession
,
Serialized FormConstructor Summary | |
---|---|
SshScript(Ssh ssh)
Constructs a new SshScript instance. |
|
SshScript(Ssh ssh,
java.lang.String terminator)
Constructs a new SshScript instance. |
Method Summary | |
---|---|
void |
addSshScriptListener(SshScriptListener listener)
Adds a SshScriptListener to this SshScript . |
void |
addTask(SshTask task)
Adds a SshTask to this SshScript. |
void |
clear()
Clears all tasks from the script. |
SshTask |
getTask(java.lang.String name)
Gets the named SshTask based on the name attribute of a SshTask. |
boolean |
isComplete()
Checks whether this SshScript has completed execution of all SshTask. |
boolean |
isEmpty()
Checks if there are any SshTask bound to this SshScript |
void |
removeSshScriptListener(SshScriptListener listener)
Removes a SshScriptListener from this SshScript |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SshScript(Ssh ssh)
ssh
- - the Ssh instance this SshScript is bound to.Ssh
public SshScript(Ssh ssh, java.lang.String terminator)
ssh
- - Ssh instance this SshScript is bound to.terminator
- the line terminator to use when executing command for a SshTaskSsh
,
SshTask
,
addTask(com.jscape.inet.ssh.SshTask)
Method Detail |
---|
public boolean isEmpty()
public void addTask(SshTask task)
task
- the SshTask to addSshTask
public SshTask getTask(java.lang.String name)
name
- the name of the SshTask to retrieve.
SshTask
public void clear()
public void addSshScriptListener(SshScriptListener listener)
SshScriptListener
to this SshScript
.
listener
- the SshScriptListener
instance to addSshScriptListener
public void removeSshScriptListener(SshScriptListener listener)
SshScriptListener
from this SshScript
listener
- the SshScriptListener
instance to removeSshScriptListener
public boolean isComplete()
|
SSH Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |