From 54887baf70fe5062209b03a1eab35710535bb14e Mon Sep 17 00:00:00 2001 From: Juri Leino Date: Mon, 8 Apr 2019 16:47:43 +0200 Subject: [PATCH] improve process:execute examples - add note how to expand environment variables and use globbing - add example for wildcards / globbing --- .../data/docs/process/execute.md | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/main/xar-resources/data/docs/process/execute.md b/src/main/xar-resources/data/docs/process/execute.md index 96c83bd..85a229c 100644 --- a/src/main/xar-resources/data/docs/process/execute.md +++ b/src/main/xar-resources/data/docs/process/execute.md @@ -6,6 +6,8 @@ The eXistdb process module enables admin users to execute system command on the * enviroment * stdin +If you want to print environment variables or pass wildcard character to scripts it is necessary to call *sh*, *bash* or *zsh* with the -c option and provide the command as a single third parameter. + ## Working Directory @@ -19,10 +21,11 @@ return process:execute(("ls","-l"),$options) ``` ### Result + Lists the files in the directory '/etc' in long format (-l) -## Environment Variables +## Environment Variables ```xquery let $options := \ + +process:execute(("sh", "-c", "ls *.xml"), ) +``` + +### Result + +Lists all files with xml as their file extension. + +**NOTE:** `process:execute(("ls", "*.xml"), $options)` returns an error. ## stdin The command executed via process:execute reads the value(s) given as stdin argument(s) ```xquery let $options := \ + \ + \One + \Two + \ + \ return process:execute(("wc", "-l"), $options) ``` ### Result + The Unix command 'wc -l' prints the line count of the given argument (here ). The result is '2'.