@@ -0,0 +1,1482 @@
+package com.github.aureliano.achmed.resources.exec;%0A%0Aimport java.io.File;%0Aimport java.io.InputStream;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Scanner;%0A%0Aimport com.github.aureliano.achmed.exception.ExecResourceException;%0A%0Apublic class CommandRunner implements Runnable %7B%0A%0A%09private List%3CString%3E command;%0A%09private File workingDir;%0A%09private boolean verbose;%0A%09%0A%09public CommandRunner(String command) %7B%0A%09%09this.command = Arrays.asList(command.split(%22%5C%5Cs+%22));%0A%09%7D%0A%09%0A%09public void run() %7B%0A%09%09this.execute();%0A%09%7D%0A%09%0A%09public int execute() %7B%0A%09%09ProcessBuilder builder = new ProcessBuilder(this.command);%0A%09%09builder.directory(this.workingDir);%0A%09%09%0A%09%09int exitStatus = Integer.parseInt(%221%22 + this.command.size());%0A%09%09Process process = null;%0A%09%09%0A%09%09try %7B%0A%09%09%09process = builder.start();%0A%09%09%09this.scanCommand(process);%0A%09%09%09exitStatus = process.waitFor();%0A%09%09%7D catch (Exception ex) %7B%0A%09%09%09try %7B%0A%09%09%09%09this.readError(process);%0A%09%09%09%7D catch (RuntimeException re) %7B%0A%09%09%09%09throw new ExecResourceException(re);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return exitStatus;%0A%09%7D%0A%09%0A%09private void scanCommand(Process process) %7B%0A%09%09this.consumeStream(process.getInputStream(), this.verbose);%0A%09%7D%0A%09%0A%09private void readError(Process process) %7B%0A%09%09this.consumeStream(process.getErrorStream(), true);%0A%09%7D%0A%09%0A%09private void consumeStream(InputStream stream, boolean verbose) %7B%0A%09%09Scanner scanner = new Scanner(stream);%0A%09%09%0A%09%09while (scanner.hasNextLine()) %7B%0A%09%09%09if (verbose) %7B%0A%09%09%09%09System.out.println(scanner.nextLine());%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09scanner.close();%0A%09%7D%0A%7D

Create command runner.