public class OSHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
OSHelper.ProcessReturn |
| Modifier and Type | Field and Description |
|---|---|
static int |
osh_PROCESS_EXITED_BY_ITSELF
Deprecated.
Use ProcessReturn.osh_PROCESS_EXITED_BY_ITSELF
|
static int |
osh_PROCESS_KILLED_BY_TIMEOUT
Deprecated.
Use ProcessReturn.osh_PROCESS_KILLED_BY_TIMEOUT
|
| Constructor and Description |
|---|
OSHelper() |
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
constructCommandAsList_Unix_sh(String command)
Helper method to construct a UNIX-like-OS-compatible command that is
using the SH shell syntax.
|
static List<String> |
constructCommandAsList_Windows_cmd(String command)
Helper method to construct a Windows-compatible command that is using the
CMD shell syntax.
|
static void |
copyFile(String sourceFileName,
String targetFileName)
Copy files
|
static int |
procWait(Process process)
Deprecated.
Use ProcessReturn procWaitWithProcessReturn () instead
|
static int |
procWait(Process process,
long timeout)
Deprecated.
Use ProcessReturn procWaitWithProcessReturn () instead
|
static OSHelper.ProcessReturn |
procWaitWithProcessReturn(Process process) |
static OSHelper.ProcessReturn |
procWaitWithProcessReturn(Process process,
long timeout)
Waits for a specified process to terminate for the specified amount of
milliseconds.
|
static byte[] |
readFile(String fileName)
Read a file to a byte array
|
static Process |
runCommand(List<String> toRun)
Runs a new OS process
|
static OSHelper.ProcessReturn |
sendEmail_Unix(String target,
String topic,
String text)
Send a simple email
|
static void |
writeFile(byte[] bytes,
String targetFileName)
Write a file
|
public static final int osh_PROCESS_EXITED_BY_ITSELF
public static final int osh_PROCESS_KILLED_BY_TIMEOUT
public static Process runCommand(List<String> toRun) throws OSHelperException
toRun - OS console command to runOSHelperExceptionpublic static OSHelper.ProcessReturn procWaitWithProcessReturn(Process process) throws OSHelperException
OSHelperExceptionpublic static OSHelper.ProcessReturn procWaitWithProcessReturn(Process process, long timeout) throws OSHelperException
process - timeout - OSHelperExceptionpublic static int procWait(Process process) throws OSHelperException
process - OSHelperExceptionpublic static int procWait(Process process, long timeout) throws OSHelperException
process - timeout - osh_PROCESS_EXITED_BY_ITSELF * * *
or osh_PROCESS_KILLED_BY_TIMEOUTOSHelperExceptionpublic static byte[] readFile(String fileName) throws OSHelperException
fileName - OSHelperExceptionpublic static void writeFile(byte[] bytes,
String targetFileName)
throws OSHelperException
bytes - targetFileName - OSHelperExceptionpublic static void copyFile(String sourceFileName, String targetFileName) throws OSHelperException
sourceFileName - targetFileName - OSHelperExceptionpublic static OSHelper.ProcessReturn sendEmail_Unix(String target, String topic, String text) throws OSHelperException
target - topic - text - stdout and stderr, 0 * for exitCode
and osh_PROCESS_EXITED_BY_ITSELF for exitStatusOSHelperExceptionOSHelper.ProcessReturnpublic static List<String> constructCommandAsList_Unix_sh(String command)
command - Copyright © 2013. All rights reserved.