public class SshScript extends java.lang.Object implements SshListener, SshTask.Listener, java.io.Serializable
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 Form| Constructor and Description |
|---|
SshScript(Ssh ssh)
Constructs a new SshScript instance.
|
SshScript(Ssh ssh,
java.lang.String endOfLine)
Constructs a new SshScript instance.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
void |
connected(SshConnectedEvent event)
Invoked when SSH connection is established.
|
void |
dataReceived(SshDataReceivedEvent event)
Invoked when data is received from SSH server.
|
void |
disconnected(SshDisconnectedEvent event)
Invoked when SSH connection is released.
|
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 |
onTaskCancelled(SshTask task) |
void |
onTaskCompleted(SshTask task) |
void |
onTaskError(SshTask task,
java.lang.Exception error) |
void |
onTaskTimeout(SshTask task) |
void |
removeSshScriptListener(SshScriptListener listener)
Removes a
SshScriptListener from this SshScript |
public SshScript(Ssh ssh, java.lang.String endOfLine)
ssh - - Ssh instance this SshScript is bound to.endOfLine - the line terminator to use when executing command for a SshTaskSsh,
SshTask,
addTask(com.jscape.inet.ssh.SshTask)public void addTask(SshTask task)
task - the SshTask to addSshTaskpublic SshTask getTask(java.lang.String name)
name - the name of the SshTask to retrieve.SshTaskpublic boolean isEmpty()
public boolean isComplete()
public void clear()
public void addSshScriptListener(SshScriptListener listener)
SshScriptListener to this SshScript.listener - the SshScriptListener instance to addSshScriptListenerpublic void removeSshScriptListener(SshScriptListener listener)
SshScriptListener from this SshScriptlistener - the SshScriptListener instance to removeSshScriptListenerpublic void connected(SshConnectedEvent event)
SshListenerconnected in interface SshListenerevent - a SshConnectedEventSshConnectedEventpublic void disconnected(SshDisconnectedEvent event)
SshListenerdisconnected in interface SshListenerevent - a SshDisconnectedEventSshDisconnectedEventpublic void dataReceived(SshDataReceivedEvent event)
SshListenerdataReceived in interface SshListenerevent - a SshDataReceivedEventpublic void onTaskCompleted(SshTask task)
onTaskCompleted in interface SshTask.Listenerpublic void onTaskCancelled(SshTask task)
onTaskCancelled in interface SshTask.Listenerpublic void onTaskError(SshTask task, java.lang.Exception error)
onTaskError in interface SshTask.Listenerpublic void onTaskTimeout(SshTask task)
onTaskTimeout in interface SshTask.ListenerCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved