Skip to content
QiTASC.com / intaQt Built-ins /
Executor Built-ins
/ .. /
Executor Built-ins





Executor Built-ins

Executor Built-ins execute any process available via the command line. The execute function sends a command, which is returned as an instance of a process object. Additional Built-in functions examine the status of the process running the command.

Example

1
2
3
4
5
6
process := Executor.execute("ls dir")
if process.waitFor(20000) then
  println("Output: " + process.output("UTF-8"))
  println("Error: " + process.error("UTF-8"))
  println("Exit value:" + process.exitValue())
end

Create Executor Process

To use Executor Built-ins, a process must first be started.

Syntax

1
<process Process> := Executor.execute(<cmd String>)

Returns

The Executor process.

Parameter

  • cmd - The command being sent
    • Anything that can be invoked from the Terminal can be invoked by the execute function

Example

1
process := Executor.execute("ls dir")

Executor Built-ins Functions

Wait For

Waits until the process has terminated or the specified waiting time elapses.

Syntax

1
<isExitedInTime Boolean> := process.waitFor(<timeoutMilliseconds Number>)

Returns

true if the process has already terminated, false otherwise.

Parameter

  • timeoutMilliseconds - The maximum time to wait in milliseconds

Example

1
isExitedInTime := process.waitFor(20000)

Output

Returns the normal output of the process.

Syntax

1
<output String> := process.output(<charset String>)

Returns

The process' output.

Parameter

  • charset (Optional) - The character set for reading the output
    • Default is set to UTF-8

Example

1
processoutput := process.output("UTF-8")

Note: This function does not wait for process termination.

Error

Returns the process' error output.

Syntax

1
<error String> := process.error(<charset String>)

Returns

The error output.

Parameter

  • charset - the character set for reading the error output
    • Default is set to UTF-8

Example

1
processerror := process.error("UTF-8")

Note: This function does not wait for process termination.

Input

Writes to the process. An error will occur if the process is already terminated when this function is executed.

Syntax

1
<processInput String> := process.input(<input String>)

Returns

The process input.

Parameter

  • input - The string sent to the process

Example

1
newinput := process.input("abc")

Is Alive

Checks if the process has been terminated or not.

Syntax

1
<result Boolean> := process.isAlive()

Returns

false if the process has terminated, true otherwise.

Example

1
2
3
if process.isAlive() then
    println("it's alive!")
end

Exit Value

Returns the process' exit value.

Syntax

1
<result Number> := process.exitValue()

Returns

The exit value's number. null if the process has not terminated.

Example

1
2
3
4
5
6
7
echoProcess := Executor.execute("echo abc")
println("OUT:" + echoProcess.output())
println("ExitValue:" + sleepProcess.exitValue())

sleepProcess := Executor.execute("sleep 10")
println("WAIT: " + sleepProcess.waitFor(3000))
println("ExitValue:" + sleepProcess.exitValue())

Kill

Terminates a running process.

Syntax

1
process.kill()

Example

1
2
3
4
5
6
stepdef "abort sleep"
    process := Executor.execute("sleep 30")
    if process.isAlive() then
        process.kill()
    end
end