Package org.terracotta.utilities.exec
Class Shell
- java.lang.Object
-
- org.terracotta.utilities.exec.Shell
-
public final class Shell extends java.lang.ObjectUtility functions for use with execution of shell commands.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShell.EncodingSingleton identifying theCharsetused for encoding/decoding interactions with the "shell" command interpreter environment.static classShell.ResultTheexecute(Charset, String...)command execution result.
-
Field Summary
Fields Modifier and Type Field Description private static booleanIS_WINDOWSprivate static org.slf4j.LoggerLOGGER
-
Constructor Summary
Constructors Modifier Constructor Description privateShell()Private niladic constructor to prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Shell.Resultexecute(java.nio.charset.Charset consoleEncoding, java.lang.String... command)Executes a command in the host and returns the command output, both stdout and stderr, as a list of strings.
-
-
-
Method Detail
-
execute
public static Shell.Result execute(java.nio.charset.Charset consoleEncoding, java.lang.String... command) throws java.io.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- 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:
java.io.IOException- if an error is raised while executing the command or retrieving the results
-
-