Prototype for System.Process objects, derived from System.Synchronization.Waitable object.
Use the launch method to run a process.
none.
none.
ECMerge 2.1
System.Process allows execution, both synchronously and
asynchronously, of a command line. It allows also input/output
redirection as well as exit code checking...
Such an object can be used as a synchronization object, that is
you can use the wait function on it.
Property | Description |
termination_state |
Error object or undefined. In case of success of the execution this property is undefined, else it contains an Error object. Here 'success of the execution' must be understood as simply being able to run the program (there is no expectation relatively to the program result itself). [Currently available only on Windows platform] |
launch
(static method)
(see methods of System.Synchronization.Waitable
object)
function launch
(command_line, context)
returns a System.Process when using the asynchronous version,
else undefined.
command_line. String. Program to execute with its
arguments.
context. Object. This simple object (created with 'new Object'
for example) contains various members which parameter how the
command line should be run. It can be ommitted, in which case
it is interpreted as an object object as defined by 'new
Object'.
Property | Description |
asynchronous | If defined and true, the process is launched asynchronously |
redirections.input | If defined, the process input is redirected to the value found there. If the value is a URL the file is loaded and provided binarily as input, if the value is a string, it is a provided to the process input directly, encoded as specified by redirections.input_encoding_properies. |
redirections.input_encoding_properies | EncodingProperties object. Specifies how to write string input to the process, if not specified default system encoding is used. |
redirections.output / .error | If defined, the process output (or error) is redirected to the value found there. If the value is a URL the output is saved binarily at that location, if the value is a string it will be overwritten by the returned text, converted to Unicode using redirections.output_encoding_properies / .error_encoding_properties as the source encoding. |
redirections.output_encoding_properies redirections.error_encoding_properies |
EncodingProperties object. Specifies how to read string output from the process, if not specified default system encoding is used. |
exit_code | int32. Filled when the process actually ends with its exit code. |
System.Process object.
ECMerge 2.1.76
Launches a process described by "command_line", in
conditions set in "context".
The asynchronous version (with
"context.asynchronous = true") returns immediately after
running the process and does not wait for the process to
return. A System.Process object is returned which refers to the
run process. By default, the life time of the process is tied
to that of the System.Process object, when the object is
garbage collected the launched process is cancelled if not yet
terminated.
The synchronous version calls
System.Synchronization.wait ( ) internally.
This sample runs a list command on Unix systems and gets the results back into a string.
var context = { redirections: { output: "" } };
System.Process.launch ("ls /", context);
alert (context.redirections.output);
This sample runs another list command asynchronously on Unix systems, wait for its termination and gets the results back into a string.
var context = { asynchronous: true,
redirections: { output: "" } };
var process = System.Process.launch ("ls /", context);
System.Synchronization.Waitable.wait
(process);
alert (context.redirections.output);