Package org.apache.sshd.server.shell
Class ProcessShell
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.server.shell.ProcessShell
- All Implemented Interfaces:
SessionContextHolder
,SessionHolder<ServerSession>
,ServerChannelSessionHolder
,CommandLifecycle
,ServerSessionAware
,ServerSessionHolder
,InvertedShell
Bridges the I/O streams between the SSH command and the process that executes it
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ChannelSession
private String
private TtyFilterInputStream
private TtyFilterOutputStream
private TtyFilterInputStream
private Process
private ServerSession
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy
(ChannelSession channel) This method is called by the SSH server to destroy the command because the client has disconnected somehow.int
Retrieve the exit value of the shell.Returns the output stream used to feed the shell.boolean
isAlive()
Check if the underlying shell is still aliveresolveShellTtyOptions
(Map<PtyMode, Integer> modes) void
setSession
(ServerSession session) void
start
(ChannelSession channel, Environment env) Starts the command execution.toString()
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sshd.server.shell.InvertedShell
getSession
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
Field Details
-
command
-
cmdValue
-
session
-
channelSession
-
process
-
in
-
out
-
err
-
-
Constructor Details
-
ProcessShell
- Parameters:
command
- The command components which when joined (with space separator) create the full command to be executed by the shell
-
ProcessShell
-
-
Method Details
-
getServerSession
- Specified by:
getServerSession
in interfaceServerSessionHolder
- Returns:
- The underlying
ServerSession
used
-
setSession
- Specified by:
setSession
in interfaceServerSessionAware
- Parameters:
session
- TheServerSession
in which this shell will be executed.
-
getServerChannelSession
- Specified by:
getServerChannelSession
in interfaceServerChannelSessionHolder
-
start
Description copied from interface:CommandLifecycle
Starts the command execution. All streams must have been set before calling this method. The command should implementRunnable
, and this method should spawn a new thread like:Thread(this).start();
- Specified by:
start
in interfaceCommandLifecycle
- Parameters:
channel
- TheChannelSession
through which the command has been receivedenv
- TheEnvironment
- Throws:
IOException
- If failed to start
-
resolveShellEnvironment
-
resolveShellTtyOptions
-
getInputStream
Description copied from interface:InvertedShell
Returns the output stream used to feed the shell. This method is called after the shell has been started.- Specified by:
getInputStream
in interfaceInvertedShell
- Returns:
- The
OutputStream
used to feed the shell
-
getOutputStream
- Specified by:
getOutputStream
in interfaceInvertedShell
- Returns:
- The
InputStream
representing the output stream of the shell
-
getErrorStream
- Specified by:
getErrorStream
in interfaceInvertedShell
- Returns:
- The
InputStream
representing the error stream of the shell
-
isAlive
public boolean isAlive()Description copied from interface:InvertedShell
Check if the underlying shell is still alive- Specified by:
isAlive
in interfaceInvertedShell
- Returns:
true
if alive
-
exitValue
public int exitValue()Description copied from interface:InvertedShell
Retrieve the exit value of the shell. This method must only be called when the shell is not alive anymore.- Specified by:
exitValue
in interfaceInvertedShell
- Returns:
- the exit value of the shell
-
destroy
Description copied from interface:CommandLifecycle
This method is called by the SSH server to destroy the command because the client has disconnected somehow.- Specified by:
destroy
in interfaceCommandLifecycle
- Parameters:
channel
- TheChannelSession
through which the command has been received
-
toString
-