public class ShellUtils
extends java.lang.Object
checkRootPermission()
Modifier and Type | Class and Description |
---|---|
static class |
ShellUtils.CommandResult
result of command
ShellUtils.CommandResult.result means result of command, 0 means normal, else means error, same to excute in
linux shell
ShellUtils.CommandResult.successMsg means success message of command result
ShellUtils.CommandResult.errorMsg means error message of command result
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMMAND_EXIT |
static java.lang.String |
COMMAND_LINE_END |
static java.lang.String |
COMMAND_SH |
static java.lang.String |
COMMAND_SU |
Constructor and Description |
---|
ShellUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkRootPermission()
check whether has root permission
|
static ShellUtils.CommandResult |
execCommand(java.util.List<java.lang.String> commands,
boolean isRoot)
execute shell commands, default return result msg
|
static ShellUtils.CommandResult |
execCommand(java.util.List<java.lang.String> commands,
boolean isRoot,
boolean isNeedResultMsg)
execute shell commands
|
static ShellUtils.CommandResult |
execCommand(java.lang.String[] commands,
boolean isRoot)
execute shell commands, default return result msg
|
static ShellUtils.CommandResult |
execCommand(java.lang.String[] commands,
boolean isRoot,
boolean isNeedResultMsg)
execute shell commands
|
static ShellUtils.CommandResult |
execCommand(java.lang.String command,
boolean isRoot)
execute shell command, default return result msg
|
static ShellUtils.CommandResult |
execCommand(java.lang.String command,
boolean isRoot,
boolean isNeedResultMsg)
execute shell command
|
public static final java.lang.String COMMAND_SU
public static final java.lang.String COMMAND_SH
public static final java.lang.String COMMAND_EXIT
public static final java.lang.String COMMAND_LINE_END
public static boolean checkRootPermission()
public static ShellUtils.CommandResult execCommand(java.lang.String command, boolean isRoot)
command
- commandisRoot
- whether need to run with rootexecCommand(String[], boolean, boolean)
public static ShellUtils.CommandResult execCommand(java.util.List<java.lang.String> commands, boolean isRoot)
commands
- command listisRoot
- whether need to run with rootexecCommand(String[], boolean, boolean)
public static ShellUtils.CommandResult execCommand(java.lang.String[] commands, boolean isRoot)
commands
- command arrayisRoot
- whether need to run with rootexecCommand(String[], boolean, boolean)
public static ShellUtils.CommandResult execCommand(java.lang.String command, boolean isRoot, boolean isNeedResultMsg)
command
- commandisRoot
- whether need to run with rootisNeedResultMsg
- whether need result msgexecCommand(String[], boolean, boolean)
public static ShellUtils.CommandResult execCommand(java.util.List<java.lang.String> commands, boolean isRoot, boolean isNeedResultMsg)
commands
- command listisRoot
- whether need to run with rootisNeedResultMsg
- whether need result msgexecCommand(String[], boolean, boolean)
public static ShellUtils.CommandResult execCommand(java.lang.String[] commands, boolean isRoot, boolean isNeedResultMsg)
commands
- command arrayisRoot
- whether need to run with rootisNeedResultMsg
- whether need result msgShellUtils.CommandResult.successMsg
is null and ShellUtils.CommandResult.errorMsg
is
null.ShellUtils.CommandResult.result
is -1, there maybe some excepiton.