Package javaforce
Class ShellProcess
java.lang.Object
javaforce.ShellProcess
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEnvironmentVariable(String name, String value) voidaddListener(ShellProcessListener listener) The listener will receive all output.voidaddRegexResponse(String prompt_regex, String reply, boolean repeat) Registers a response to a prompt in the form of a regex.voidaddRegexTerminate(String prompt_regex) Terminates the program if prompt_regex is detected.voidaddResponse(String prompt, String reply, boolean repeat) Registers a response to a prompt.voidaddTerminate(String prompt) Terminates the program if prompt is detected.voiddestroy()Terminates the process.voidForcibly Terminates the process.static ShellProcess.OutputExecutes a command and returns the ShellProcess.Output with stdout, stderr and errorLevel.static ShellProcess.OutputExecutes a command and returns the ShellProcess.Output with stdout, stderr and errorLevel.intReturns error level from last process run.voidinherit(boolean state) booleanisAlive()voidkeepOutput(boolean state) Keep all output (default).voidRuns a process, sending responses to stdin and returning all stdout.See run(String cmd[], boolean redirStderr)voidSets init working folder.
-
Field Details
-
log
public static boolean log -
logPrompt
public static boolean logPrompt -
command
-
-
Constructor Details
-
ShellProcess
public ShellProcess()
-
-
Method Details
-
addResponse
Registers a response to a prompt. If repeat is true the response can be used many times. -
addTerminate
Terminates the program if prompt is detected. -
addRegexResponse
Registers a response to a prompt in the form of a regex. If repeat is true the response can be used many times. -
addRegexTerminate
Terminates the program if prompt_regex is detected. -
addListener
The listener will receive all output. -
getListener
-
addEnvironmentVariable
-
removeEnvironmentVariable
-
setFolder
Sets init working folder. -
keepOutput
public void keepOutput(boolean state) Keep all output (default). Note that responses are disabled when this is disabled. Disabling this is intended for long processes that are monitored with a ShellProcessListener -
inherit
public void inherit(boolean state) -
run
See run(String cmd[], boolean redirStderr) -
run
Runs a process, sending responses to stdin and returning all stdout. The responses should cause the process to terminate. If cmd[0] is 'sudo' then jfsudo-ask is used if a password is required to run the command. If redirStderr is true then stderr will be redir to stdout. -
destroy
public void destroy()Terminates the process. -
destroyForcibly
public void destroyForcibly()Forcibly Terminates the process. -
getStdout
-
getStderr
-
getOutput
-
getErrorLevel
public int getErrorLevel()Returns error level from last process run. -
getOutputStream
-
isAlive
public boolean isAlive() -
getProcess
-
exec
Executes a command and returns the ShellProcess.Output with stdout, stderr and errorLevel. -
exec
Executes a command and returns the ShellProcess.Output with stdout, stderr and errorLevel. stderr is NOT redirected to stdout.
-