Interface ClientChannel

    • Method Detail

      • getChannelType

        String getChannelType()
        Returns:
        The type of channel reported when it was created
      • getInvertedIn

        OutputStream getInvertedIn()
        Obtains an OutputStream to send data directly to the remote end of the channel. This can be used instead of using setIn(InputStream) method and having the channel polling for data in that stream.

        When the channel closes, it will close the returned stream.

        This method should be called only after the channel has been opened.

        Returns:
        an OutputStream for sending data, or null if an input stream was set via setIn(InputStream)
        See Also:
        setIn(InputStream)
      • getInvertedOut

        InputStream getInvertedOut()
        Obtains an InputStream to read received SshConstants.SSH_MSG_CHANNEL_DATA data directly from the channel. This is an alternative to setOut(OutputStream). If the error stream is redirected to the output stream via setRedirectErrorStream(true), this stream will also receive SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA data.

        When the channel closes, it will not close the returned stream. It is the caller's responsibility to close the returned stream if needed. Closing the stream while the channel is open may cause the channel to be closed forcibly if more data arrives. The stream remains open after the channel has closed, so that the caller can read the last arrived data even afterwards.

        As with all external processes, the application should read this stream to avoid that the channel blocks when the stream's buffer is full. The buffer size for the returned stream is bounded by the channel's local window size. If the caller does not read this stream, the channel will block once the local window is exhausted.

        This method should be called only after the channel has been opened.

        Returns:
        an InputStream for reading received data, or null if an output stream was set via setOut(OutputStream)
        See Also:
        setOut(OutputStream), setRedirectErrorStream(boolean)
      • getInvertedErr

        InputStream getInvertedErr()
        Obtains an InputStream to read received SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA data directly from the channel. This is an alternative to setErr(OutputStream). If the error stream is redirected to the output stream via setRedirectErrorStream(true), the returned stream will not receive any data and be always at EOF.

        When the channel closes, it will not close the returned stream. It is the caller's responsibility to close the returned stream if needed. Closing the stream while the channel is open may cause the channel to be closed forcibly if more data arrives. The stream remains open after the channel has closed, so that the caller can read the last arrived data even afterwards.

        As with all external processes, the application should read this stream (unless it was redirected) to avoid that the channel blocks when the stream's buffer is full. The buffer size for the returned stream is bounded by the channel's local window size. If the caller does not read this stream, the channel will block once the local window is exhausted.

        This method should be called only after the channel has been opened.

        Returns:
        an InputStream for reading received data, or null if an output stream was set via setErr(OutputStream)
        See Also:
        setErr(OutputStream), setRedirectErrorStream(boolean)
      • setIn

        void setIn​(InputStream in)
        Sets an InputStream that will be read by this channel and forwarded to the remote channel. Note that using such a stream will create an additional thread for pumping the stream which will only be able to end when that stream is actually closed or EOF on the stream is reached. It is recommended to use the getInvertedIn() method instead and write data directly.

        The stream must be set before the channel is opened. When the channel closes, it will close the given stream.

        Parameters:
        in - an InputStream to be polled and forwarded
        See Also:
        getInvertedIn()
      • setRedirectErrorStream

        void setRedirectErrorStream​(boolean redirectErrorStream)
        Defines whether to redirect the error stream into the output stream; has no effect if setErr(OutputStream) has also been called by the time the channel is opened.
        Parameters:
        redirectErrorStream - whether to redirect the error stream to the output stream.
      • getExitStatus

        Integer getExitStatus()
        Returns:
        The signaled exit status via "exit-status" request - null if not signaled
      • getExitSignal

        String getExitSignal()
        Returns:
        The signaled exit signal via "exit-signal" - null if not signaled
      • validateCommandExitStatusCode

        static void validateCommandExitStatusCode​(String command,
                                                  Integer exitStatus)
                                           throws RemoteException
        Makes sure remote command exit status has been provided and it is zero
        Parameters:
        command - The command string - used only for exception text
        exitStatus - The exit status value
        Throws:
        RemoteException - If exitStatus is null or non-zero