Package org.sonar.api.utils.command
Class CommandExecutor
- java.lang.Object
-
- org.sonar.api.utils.command.CommandExecutor
-
public class CommandExecutor extends java.lang.Object
Synchronously execute a native command line. It's much more limited than the Apache Commons Exec library. For example it does not allow to run asynchronously or to automatically quote command-line arguments.- Since:
- 2.7
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandExecutor
create()
int
execute(Command command, long timeoutMilliseconds)
Execute command and display error and output streams in log.int
execute(Command command, StreamConsumer stdOut, StreamConsumer stdErr, long timeoutMilliseconds)
-
-
-
Method Detail
-
create
public static CommandExecutor create()
-
execute
public int execute(Command command, StreamConsumer stdOut, StreamConsumer stdErr, long timeoutMilliseconds)
- Parameters:
timeoutMilliseconds
- any negative value means no timeout.- Throws:
TimeoutException
- on timeout, since 4.4CommandException
- on any other error- Since:
- 3.0
-
execute
public int execute(Command command, long timeoutMilliseconds)
Execute command and display error and output streams in log. Methodexecute(Command, StreamConsumer, StreamConsumer, long)
is preferable, when fine-grained control of output of command required.- Parameters:
timeoutMilliseconds
- any negative value means no timeout.- Throws:
CommandException
-
-