public class ProcessShell extends AbstractLoggingBean implements InvertedShell, ServerSessionHolder
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
cmdValue |
private java.util.List<java.lang.String> |
command |
private TtyFilterInputStream |
err |
private TtyFilterOutputStream |
in |
private TtyFilterInputStream |
out |
private java.lang.Process |
process |
private ServerSession |
session |
log| Constructor and Description |
|---|
ProcessShell(java.util.Collection<java.lang.String> command) |
ProcessShell(java.lang.String... command) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
This method is called by the SSH server to destroy the command because
the client has disconnected somehow.
|
int |
exitValue()
Retrieve the exit value of the shell.
|
java.io.InputStream |
getErrorStream() |
java.io.OutputStream |
getInputStream()
Returns the output stream used to feed the shell.
|
java.io.InputStream |
getOutputStream() |
ServerSession |
getServerSession() |
boolean |
isAlive()
Check if the underlying shell is still alive
|
protected java.util.Map<java.lang.String,java.lang.String> |
resolveShellEnvironment(java.util.Map<java.lang.String,java.lang.String> env) |
protected java.util.Map<PtyMode,java.lang.Integer> |
resolveShellTtyOptions(java.util.Map<PtyMode,java.lang.Integer> modes) |
void |
setSession(ServerSession session) |
void |
start(Environment env)
Starts the command execution.
|
java.lang.String |
toString() |
getSimplifiedLoggerprivate final java.util.List<java.lang.String> command
private java.lang.String cmdValue
private ServerSession session
private java.lang.Process process
private TtyFilterOutputStream in
private TtyFilterInputStream out
private TtyFilterInputStream err
public ProcessShell(java.lang.String... command)
command - The command components which when joined (with space separator)
create the full command to be executed by the shellpublic ProcessShell(java.util.Collection<java.lang.String> command)
public ServerSession getServerSession()
getServerSession in interface ServerSessionHolderServerSession usedpublic void setSession(ServerSession session)
setSession in interface SessionAwaresession - The ServerSession in which this shell will be executed.public void start(Environment env) throws java.io.IOException
CommandLifecycleRunnable,
and this method should spawn a new thread like:
Thread(this).start();
start in interface CommandLifecycleenv - The Environmentjava.io.IOException - If failed to startprotected java.util.Map<java.lang.String,java.lang.String> resolveShellEnvironment(java.util.Map<java.lang.String,java.lang.String> env)
protected java.util.Map<PtyMode,java.lang.Integer> resolveShellTtyOptions(java.util.Map<PtyMode,java.lang.Integer> modes)
public java.io.OutputStream getInputStream()
InvertedShellgetInputStream in interface InvertedShellOutputStream used to feed the shellpublic java.io.InputStream getOutputStream()
getOutputStream in interface InvertedShellInputStream representing the output stream of the shellpublic java.io.InputStream getErrorStream()
getErrorStream in interface InvertedShellInputStream representing the error stream of the shellpublic boolean isAlive()
InvertedShellisAlive in interface InvertedShelltrue if alivepublic int exitValue()
InvertedShellexitValue in interface InvertedShellpublic void destroy()
CommandLifecycledestroy in interface CommandLifecyclepublic java.lang.String toString()
toString in class java.lang.Object