Class SshShellSession

java.lang.Object
com.shaft.cli.SshShellSession
All Implemented Interfaces:
AutoCloseable

public final class SshShellSession extends Object implements AutoCloseable
Experimental interactive SSH shell session backed by one JSch ChannelShell.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the shell channel and removes it from the parent terminal session.
    readUntil(Pattern pattern)
    Reads shell output until the supplied pattern matches using the configured default timeout.
    readUntil(Pattern pattern, Duration timeout)
    Reads shell output until the supplied pattern matches or the timeout elapses.
    void
    send(String text)
    Writes exact text to the remote shell without appending a newline.
    void
    Writes text plus a newline to the remote shell.
    void
    Writes exact text to the remote shell without logging the raw payload.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • send

      public void send(String text)
      Writes exact text to the remote shell without appending a newline.
    • sendLine

      public void sendLine(String text)
      Writes text plus a newline to the remote shell.
    • sendSecret

      public void sendSecret(String text)
      Writes exact text to the remote shell without logging the raw payload.
    • readUntil

      public String readUntil(Pattern pattern)
      Reads shell output until the supplied pattern matches using the configured default timeout.
    • readUntil

      public String readUntil(Pattern pattern, Duration timeout)
      Reads shell output until the supplied pattern matches or the timeout elapses.
      Returns:
      all shell output read through the end of the first match
    • close

      public void close()
      Closes the shell channel and removes it from the parent terminal session.
      Specified by:
      close in interface AutoCloseable