public class ShellUtils
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
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
|
限定符和类型 | 字段和说明 |
---|---|
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 |
构造器和说明 |
---|
ShellUtils() |
限定符和类型 | 方法和说明 |
---|---|
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.