XQuery/执行外部进程
外观
< XQuery
您需要执行一个外部进程,例如 shell 命令。
process:execute($command as xs:string, $options as node()) as item()*
目前仅记录了两个选项。工作目录和标准输入的值
<options>
<workingDir>PATH TO LOCAL FILE SYSTEM</workingDir>
<stdin><line>INPUT STRING</line></stdin>
</options>
import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";
let $cmd := 'D:\Apps\git\bin\ls.exe'
return
<results>
{process:execute($cmd, <options/>)}
</results>
以下是一个运行 git "ls" 命令的示例,该命令没有任何选项。请注意,默认值为 EXIST_HOME 目录。
<execution exitCode="0">
<commandline>D:\Apps\git\bin\ls.exe </commandline>
<stdout>
<line>Install_V2.0_20130212155217_6931977091675999583.log</line>
<line>LICENSE</line>
<line>README</line>
<line>VERSION.txt</line>
<line>atom-example.xq</line>
<line>atom-services.xml</line>
<line>autodeploy</line>
<line>backup.properties</line>
<line>bin</line>
<line>build</line>
<line>build.bat</line>
<line>build.properties</line>
<line>build.sh</line>
<line>build.xml</line>
<line>client.properties</line>
<line>client.properties.tmpl</line>
<line>collection.xconf.init</line>
<line>conf.xml</line>
<line>conf.xml.tmpl</line>
<line>descriptor.xml</line>
<line>descriptor.xml.tmpl</line>
<line>dist</line>
<line>eXist-db.app</line>
<line>examples.jar</line>
<line>exist-optional.jar</line>
<line>exist.jar</line>
<line>extensions</line>
<line>icon.bmp</line>
<line>icon.ico</line>
<line>icon.png</line>
<line>index.html</line>
<line>installer</line>
<line>lib</line>
<line>log4j.dtd</line>
<line>log4j.xml</line>
<line>mime-types.xml</line>
<line>mime-types.xml.tmpl</line>
<line>samples</line>
<line>schema</line>
<line>src</line>
<line>start.jar</line>
<line>test</line>
<line>tools</line>
<line>uninstall.jar</line>
<line>vm.properties</line>
<line>webapp</line>
</stdout>
</execution>