Class CmdThread
java.lang.Object
at.letto.basespringboot.cmd.CmdThread
- All Implemented Interfaces:
Runnable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected final String[]protected final CmdThread.CmdModeprotected final Stringprivate static final Patternprotected Throwableprotected final Stringprotected final longprivate static final AtomicLongprotected Processprotected final Dateprotected final longprotected longprotected Stringprotected final Threadprotected ThreadStatus -
Constructor Summary
ConstructorsConstructorDescriptionCmdThread(String homedir, String charset, CmdThread.CmdMode cmdMode, String... cmd) -
Method Summary
Modifier and TypeMethodDescriptionbuildProcessCommand(String commandText) private voidconfigureWorkingDirectory(ProcessBuilder processBuilder) private FilecreateScriptFile(String[] commands) static CmdThreadcreateThread(String homedir, String charset, CmdThread.CmdMode cmdMode, String... cmd) static CmdThreadcreateThread(String homedir, String charset, String... cmd) static CmdThreadcreateThreadMessage(String message) private voidprivate voidexecuteProcess(List<String> processCommand, String charsetName, Vector<String> out, Vector<String> err) voidGibt ein Kommando blau und HTML-escaped aus.protected voidhtmlCmdPlain(String cmd) Gibt ein Kommando blau aus.voidGibt eine Fehlerausgabe rot und HTML-escaped aus.protected voidhtmlErrPlain(String text) Gibt eine Fehlerausgabe rot aus.voidGibt eine normale Ausgabe HTML-escaped aus.protected voidhtmlOutPlain(String text) Gibt eine normale Ausgabe aus.booleanprivate booleanlastOutputLine(int lines) parseCommandLine(String commandText) Zerlegt eine Kommandozeile in Programm und Argumente.private voidreadStream(InputStream inputStream, Charset charset, Vector<String> target, boolean errorStream) private voidregisterStartError(String prefix, IOException ex, Vector<String> out, Vector<String> err) private static CharsetresolveCharset(String charsetName) private Pathvoidrun()private voidrunAsScript(String[] commands) final voidFührt mehrere Kommandos aus.private static StringshellQuote(String value) voidstart()voidstop()voidsystemcall(String cmd, String charset, Vector<String> out) voidFührt ein Kommando aus und wartet auf dessen Beendigung.voidtask()voidwait(int seconds) Wartet die angegebene Anzahl Sekunden.voidwaitms(int milliseconds) Wartet die angegebene Anzahl Millisekunden.
-
Field Details
-
ID_COUNTER
-
COMMAND_MARKER
-
cmdMode
-
id
protected final long id -
homedir
-
cmd
-
command
-
thread
-
starttime
protected final long starttime -
startdate
-
charset
-
stoptime
protected long stoptime -
threadStatus
-
error
-
out
-
err
-
htmlOutput
-
backlink
-
template
-
batchfile
-
p
-
-
Constructor Details
-
CmdThread
-
-
Method Details
-
createThread
-
createThread
public static CmdThread createThread(String homedir, String charset, CmdThread.CmdMode cmdMode, String... cmd) -
createThreadMessage
-
backlink
-
template
-
start
public void start() -
htmlCmd
Gibt ein Kommando blau und HTML-escaped aus. -
htmlCmdPlain
Gibt ein Kommando blau aus. Der Name wurde aus Kompatibilitätsgründen beibehalten. -
htmlOut
Gibt eine normale Ausgabe HTML-escaped aus. -
htmlOutPlain
Gibt eine normale Ausgabe aus. Der Name wurde aus Kompatibilitätsgründen beibehalten. -
htmlErr
Gibt eine Fehlerausgabe rot und HTML-escaped aus. -
htmlErrPlain
Gibt eine Fehlerausgabe rot aus. Der Name wurde aus Kompatibilitätsgründen beibehalten. -
runCmd
Führt mehrere Kommandos aus. -
isScriptMode
private boolean isScriptMode() -
runAsScript
-
createScriptFile
- Throws:
IOException
-
resolveWorkingDirectoryForTempFile
- Throws:
IOException
-
shellQuote
-
task
public void task() -
run
-
getHtmlOutput
-
systemcall
-
systemcall
-
buildProcessCommand
- Throws:
IOException
-
parseCommandLine
Zerlegt eine Kommandozeile in Programm und Argumente. Unterstützt einfache und doppelte Anführungszeichen sowie Backslash- Escaping. Shell-Operatoren wie|,>,&&oder Variablenexpansion werden im NORMAL-Modus absichtlich nicht ausgewertet.- Throws:
IOException
-
executeProcess
private void executeProcess(List<String> processCommand, String charsetName, Vector<String> out, Vector<String> err) throws IOException - Throws:
IOException
-
configureWorkingDirectory
- Throws:
IOException
-
readStream
private void readStream(InputStream inputStream, Charset charset, Vector<String> target, boolean errorStream) -
resolveCharset
-
registerStartError
-
deleteBatchFile
private void deleteBatchFile() -
stop
public void stop() -
getTimeInfoHTML
-
isFinished
public boolean isFinished() -
getCmdDto
-
lastOutputLine
-
wait
public void wait(int seconds) Wartet die angegebene Anzahl Sekunden. -
waitms
public void waitms(int milliseconds) Wartet die angegebene Anzahl Millisekunden.
-