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 FormConstructor 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 addSshTask
public SshTask getTask(java.lang.String name)
name
- the name of the SshTask to retrieve.SshTask
public boolean isEmpty()
public boolean isComplete()
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 SshScriptlistener
- the SshScriptListener
instance to removeSshScriptListener
public void connected(SshConnectedEvent event)
SshListener
connected
in interface SshListener
event
- a SshConnectedEventSshConnectedEvent
public void disconnected(SshDisconnectedEvent event)
SshListener
disconnected
in interface SshListener
event
- a SshDisconnectedEventSshDisconnectedEvent
public void dataReceived(SshDataReceivedEvent event)
SshListener
dataReceived
in interface SshListener
event
- a SshDataReceivedEventpublic void onTaskCompleted(SshTask task)
onTaskCompleted
in interface SshTask.Listener
public void onTaskCancelled(SshTask task)
onTaskCancelled
in interface SshTask.Listener
public void onTaskError(SshTask task, java.lang.Exception error)
onTaskError
in interface SshTask.Listener
public void onTaskTimeout(SshTask task)
onTaskTimeout
in interface SshTask.Listener
Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved