http://www.zorba-xquery.com/modules/process
Description
Before using any of the functions below please remember to import the module namespace:
import module namespace process = "http://www.zorba-xquery.com/modules/process";This module provides functions to create a native process and return the result (i.e. exit code, result on standard out and error). Example:
import module namespace proc = "http://www.zorba-xquery.com/modules/process";
proc:exec("ls")
Potential result:
<result xmlns="http://www.zorba-xquery.com/modules/process"> <stdout>myfile.txt</stout> <stderr/> <exit-code>0</exit-code> </result>
Author
Cezar Andrei
XQuery version and encoding
xquery version "3.0" encoding "utf-8";
Namespaces
| an | http://www.zorba-xquery.com/annotations |
| process | http://www.zorba-xquery.com/modules/process |
| ver | http://www.zorba-xquery.com/options/versioning |
Functions
exec#1
declare %an:sequential function process:exec(
$cmd as xs:string
) as element(process:result) externalExecutes the specified string command in a separate process. This function does not allow arguments to be passed to the command.
Parameters
$cmd as xs:stringcommand to be executed (without arguments)
Returns
element(process:result)the result of the execution as an element as shown in the documentation of this module. The exit-code element returns the exit code of the child process. For POSIX compliant platforms: returns the process exit code. If process is terminated or stopped: 128 + termination signal code. For Windows platforms: returns the return value of the process or the exit or terminate process specified value.
Errors
- process:PROC01 if an error occurred while communicating with the executed process.
exec#2
declare %an:sequential function process:exec(
$cmd as xs:string,
$args as xs:string*
) as element(process:result) externalExecutes the specified string command in a separate process. Each of the strings in the sequence passed in as the second argument is passed as an argument to the executed command.
Parameters
$cmd as xs:stringcommand to be executed (without arguments)$args as xs:stringthe arguments passed to the executed command (e.g. "-la")
Returns
element(process:result)the result of the execution as an element as shown in the documentation of this module. The exit-code element returns the exit code of the child process. For POSIX compliant platforms: returns the process exit code. If process is terminated or stopped: 128 + termination signal code. For Windows platforms: returns the return value of the process or the exit or terminate process specified value.
Errors
- process:PROC01 if an error occurred while communicating with the executed process.