public final class RemoteCommandExecutor extends Object
Constructor and Description |
---|
RemoteCommandExecutor() |
Modifier and Type | Method and Description |
---|---|
void |
connect(String host,
int port,
String username,
String password)
Connects this executor to the remote system.
|
void |
disconnect()
Disconnects this executor to the remote system.
|
int |
exec(String command)
Handy method for
exec(String, OutputStream, boolean) with no dump
output stream. |
int |
exec(String command,
OutputStream dumpOutputStream)
Handy method for
exec(String, OutputStream, boolean) with
specified dump output stream (but no closing). |
int |
exec(String command,
OutputStream dumpOutputStream,
boolean closeDumpOutputStream)
Executes the specified command.
|
int |
exec(String command,
OutputStream dumpOutputStream,
boolean closeDumpOutputStream,
RemoteCommandExecutorCallback callback)
Executes the specified command.
|
boolean |
isConnected()
Checks if this executor is connected to the remote system.
|
public void connect(String host, int port, String username, String password) throws com.jcraft.jsch.JSchException
host
- the host name, or address, of the remote systemport
- the port number of the remote systemusername
- the user namepassword
- the user's passwordcom.jcraft.jsch.JSchException
- if a JCraft error occurspublic boolean isConnected()
true
if executor is connected, false
otherwisepublic void disconnect()
public int exec(String command) throws IOException, com.jcraft.jsch.JSchException
exec(String, OutputStream, boolean)
with no dump
output stream.command
- the command to be executed0
indicates normal termination | take care that
JSch
is also returning -1
)IOException
- if an I/O error occurscom.jcraft.jsch.JSchException
- if a JCraft error occurspublic int exec(String command, OutputStream dumpOutputStream) throws IOException, com.jcraft.jsch.JSchException
exec(String, OutputStream, boolean)
with
specified dump output stream (but no closing).command
- the command to be executeddumpOutputStream
- the stream where the process will dump (exhaust) his contents0
indicates normal termination | take care that
JSch
is also returning -1
)IOException
- if an I/O error occurscom.jcraft.jsch.JSchException
- if a JCraft error occurspublic int exec(String command, OutputStream dumpOutputStream, boolean closeDumpOutputStream) throws IOException, com.jcraft.jsch.JSchException
command
- the command to be executeddumpOutputStream
- the stream where the process will dump (exhaust) his contentscloseDumpOutputStream
- true
if the dump stream should be closed when the
execution ends, false
otherwise0
indicates normal termination | take care that
JSch
is also returning -1
)IOException
- if an I/O error occurscom.jcraft.jsch.JSchException
- if a JCraft error occurspublic int exec(String command, OutputStream dumpOutputStream, boolean closeDumpOutputStream, RemoteCommandExecutorCallback callback) throws IOException, com.jcraft.jsch.JSchException
command
- the command to be executeddumpOutputStream
- the stream where the process will dump (exhaust) his contentscloseDumpOutputStream
- true
if the dump stream should be closed when the
execution ends, false
otherwisecallback
- the callback used to do things after the execution started0
indicates normal termination | take care that
JSch
is also returning -1
)IOException
- if an I/O error occurscom.jcraft.jsch.JSchException
- if a JCraft error occursCopyright © 2013–2014 Cristian Sulea. All rights reserved.