Class ProcessShell

    • Constructor Detail

      • ProcessShell

        public ProcessShell​(java.lang.String... command)
        Parameters:
        command - The command components which when joined (with space separator) create the full command to be executed by the shell
      • ProcessShell

        public ProcessShell​(java.util.Collection<java.lang.String> command)
    • Method Detail

      • start

        public void start​(ChannelSession channel,
                          Environment env)
                   throws java.io.IOException
        Description copied from interface: CommandLifecycle
        Starts the command execution. All streams must have been set before calling this method. The command should implement Runnable, and this method should spawn a new thread like:
         
         Thread(this).start();
         
         
        Specified by:
        start in interface CommandLifecycle
        Parameters:
        channel - The ChannelSession through which the command has been received
        env - The Environment
        Throws:
        java.io.IOException - If failed to start
      • resolveShellEnvironment

        protected java.util.Map<java.lang.String,​java.lang.String> resolveShellEnvironment​(java.util.Map<java.lang.String,​java.lang.String> env)
      • resolveShellTtyOptions

        protected java.util.Map<PtyMode,​java.lang.Integer> resolveShellTtyOptions​(java.util.Map<PtyMode,​java.lang.Integer> modes)
      • getInputStream

        public java.io.OutputStream 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 interface InvertedShell
        Returns:
        The OutputStream used to feed the shell
      • getOutputStream

        public java.io.InputStream getOutputStream()
        Specified by:
        getOutputStream in interface InvertedShell
        Returns:
        The InputStream representing the output stream of the shell
      • getErrorStream

        public java.io.InputStream getErrorStream()
        Specified by:
        getErrorStream in interface InvertedShell
        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 interface InvertedShell
        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 interface InvertedShell
        Returns:
        the exit value of the shell
      • destroy

        public void destroy​(ChannelSession channel)
        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 interface CommandLifecycle
        Parameters:
        channel - The ChannelSession through which the command has been received
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object