Package org.photonvision.common.util
Class ShellExec
java.lang.Object
org.photonvision.common.util.ShellExec
Execute external process and optionally read output buffer.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Execute a command in current folder, and wait for process to endint
Execute a command.int
executeBashCommand
(String command) int
executeBashCommand
(String command, boolean wait) Execute a bash command.getError()
int
boolean
boolean
-
Constructor Details
-
ShellExec
public ShellExec() -
ShellExec
public ShellExec(boolean readOutput, boolean readError)
-
-
Method Details
-
executeBashCommand
- Throws:
IOException
-
executeBashCommand
Execute a bash command. We can handle complex bash commands including multiple executions (; | and ||), quotes, expansions ($), escapes (\), e.g.: "cd /abc/def; mv ghi 'older ghi '$(whoami)"- Parameters:
command
- Bash command to execute- Returns:
- true if bash got started, but your command may have failed.
- Throws:
IOException
-
execute
Execute a command in current folder, and wait for process to end- Parameters:
command
- command ("c:/some/folder/script.bat" or "some/folder/script.sh")args
- 0..n command line arguments- Returns:
- process exit code
- Throws:
IOException
-
execute
Execute a command.- Parameters:
command
- command ("c:/some/folder/script.bat" or "some/folder/script.sh")workdir
- working directory or NULL to use command folderwait
- wait for process to endargs
- 0..n command line arguments- Returns:
- process exit code
- Throws:
IOException
-
getExitCode
public int getExitCode() -
isOutputCompleted
public boolean isOutputCompleted() -
isErrorCompleted
public boolean isErrorCompleted() -
getOutput
-
getError
-