Class Shell

java.lang.Object
org.terracotta.utilities.exec.Shell

public final class Shell extends Object
Utility functions for use with execution of shell commands.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Singleton identifying the Charset used for encoding/decoding interactions with the "shell" command interpreter environment.
    static final class 
    The execute(Charset, String...) command execution result.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final boolean
     
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private niladic constructor to prevent instantiation.
  • Method Summary

    Modifier and Type
    Method
    Description
    execute(Charset consoleEncoding, String... command)
    Executes a command in the host and returns the command output, both stdout and stderr, as a list of strings.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • IS_WINDOWS

      private static final boolean IS_WINDOWS
  • Constructor Details

    • Shell

      private Shell()
      Private niladic constructor to prevent instantiation.
  • Method Details

    • execute

      public static Shell.Result execute(Charset consoleEncoding, String... command) throws IOException
      Executes a command in the host and returns the command output, both stdout and stderr, as a list of strings. This method blocks until the command is complete and its output consumed.
      Parameters:
      consoleEncoding - the Charset to use for decoding the command response
      command - the command to execute; this command is presented to ProcessBuilder.command() and must be properly quoted for the OS
      Returns:
      the command result
      Throws:
      IOException - if an error is raised while executing the command or retrieving the results