import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays;
import java.util.List;
+import java.util.StringJoiner;
import java.util.UUID;
import java.util.stream.Collectors;
private static boolean executeCommand(List<String> command) {
try {
+ /* "echo" the command to stdout */
+ StringJoiner sj = new StringJoiner(" ", "$ ", "");
+ command.stream().forEach(sj::add);
+ System.out.println(sj.toString());
+
ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectErrorStream(true);
builder.redirectOutput(Redirect.INHERIT);
Process p = builder.start();
int ret = p.waitFor();
+
+ System.out.println("(returned from command)");
+
return (ret == 0);
} catch (IOException | InterruptedException e) {
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
+import java.util.StringJoiner;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.log4j.LttngLogAppender;
static List<String> getOutputFromCommand(boolean print, List<String> command) {
try {
+ /* "echo" the command to stdout */
+ StringJoiner sj = new StringJoiner(" ", "$ ", "");
+ command.stream().forEach(sj::add);
+ System.out.println(sj.toString());
+
Path tempFile = Files.createTempFile("test-output", null);
ProcessBuilder builder = new ProcessBuilder(command);
if (print) {
/* Also print the output to the console */
- lines.stream().forEach(s -> System.out.println(s));
+ lines.stream().forEach(System.out::println);
+ } else {
+ System.out.println("(output silenced)");
}
+ System.out.println("(returned from command)");
return lines;
} catch (IOException | InterruptedException e) {