Package org.terracotta.utilities.exec
Class Shell
java.lang.Object
org.terracotta.utilities.exec.Shell
Utility functions for use with execution of shell commands.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSingleton identifying theCharsetused for encoding/decoding interactions with the "shell" command interpreter environment.static final classTheexecute(Charset, String...)command execution result. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate static final org.slf4j.Logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateShell()Private niladic constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic Shell.ResultExecutes a command in the host and returns the command output, both stdout and stderr, as a list of strings.
-
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
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- theCharsetto use for decoding the command responsecommand- the command to execute; this command is presented toProcessBuilder.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
-