exec

fun List<String>.exec(workingDirectory: File = File(System.getProperty("user.dir")), timeout: Long = Long.MAX_VALUE, fail: Boolean = true): String

TODO.

TODO Assure JVM closes properly after process execution (dispose process resources, etc.)


fun String.exec(workingDirectory: File = File(System.getProperty("user.dir")), timeout: Long = Long.MAX_VALUE, fail: Boolean = false): String

TODO Add use case and example in documentation. TODO Support multiple words parameters by processing " and '

Run the receiver's text as a process in the host operating system. The command can have multiple lines and may or may not contain the shell continuation string (\\n).

Receiver

String holding the command to be executed.

Return

The output of the command.

Parameters

workingDirectory

Directory on which the process will be executed. Defaults to current directory.

timeout

Maximum number of seconds allowed for process execution. Defaults to the maximum long value. It must be greater than zero.

fail

If true Raise an exception if the result code is different from zero. The default value is false.

Throws

Thrown if the process return an error code (the actual code is passed inside CodedException.code and the command output is set at CodedException.message).

IllegalStateException

If the command doesn't end within the allowed time or the command string is blank, an exception will be thrown.