public abstract class Shell
extends java.lang.Object
Shell can be used to run unix commands like du or
df.| Modifier and Type | Class and Description |
|---|---|
static class |
Shell.ExitCodeException
This is an IOException with exit code added.
|
static class |
Shell.ShellCommandExecutor
A simple shell command executor.
|
| Constructor and Description |
|---|
Shell(long timeout) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
execCommand(java.lang.String... cmd)
Static method to execute a shell command.
|
static java.lang.String |
execCommand(java.lang.String[] cmd,
long timeout)
Static method to execute a shell command.
|
protected abstract java.lang.String[] |
execString()
Return an array containing the command name and its parameters
|
int |
exitCode()
get the exit code
|
protected abstract void |
parseExecResult(java.io.BufferedReader lines)
Parse the execution result
|
java.lang.Process |
process()
get the current sub-process executing the given command
|
protected void |
run() |
public Shell(long timeout)
timeout - Specifies the time in milliseconds, after which the command will be killed. -1 means no timeout.protected abstract java.lang.String[] execString()
protected abstract void parseExecResult(java.io.BufferedReader lines)
throws java.io.IOException
java.io.IOExceptionpublic int exitCode()
public java.lang.Process process()
protected void run()
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String execCommand(java.lang.String... cmd)
throws java.io.IOException
Shell interface.cmd - shell command to execute.java.io.IOExceptionpublic static java.lang.String execCommand(java.lang.String[] cmd,
long timeout)
throws java.io.IOException
Shell interface.cmd - shell command to execute.timeout - time in milliseconds after which script should be killed. -1 means no timeout.java.io.IOException