0

I am running exist-db on windows and would like to execute an external windows program.

This works inside the normal windows shell:

C:\path\to\webGLRtiMaker.exe C:\path\to\ImageFile.rti -q 90

And I would like to execute the same program from my xquery script (I have uploaded all the needed files according to my specified paths to my exist-db):

xquery version '3.1';

import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";

declare variable $options :=    '<options>
                                    <workingDir>/db/apps/test-project/images</workingDir>
                                    <stdin><line>/db/apps/execute-test/images/image1.rti -q 90</line></stdin>
                                </options>';

(:process:execute($webRtiMaker, <options/>):)
process:execute('/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe', $options)

Even if I only execute the program without parameters (if I execute it inside windows I get the parameters as overview inside the command prompt so I should also receive some kind of output):

process:execute('/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe', <options/>)

But I get the error:

exerr:ERROR An IO error occurred while executing the process /db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe: Cannot run program "/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe": CreateProcess error=2, The System cannot find the file ...

I used this as reference: Execute External Process

What am I doing wrong?

creativeDev
  • 1,113
  • 2
  • 13
  • 20

2 Answers2

3

I have not tried this recently, but try the following:

import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";

let $cmd := 'C:\path\to\webGLRtiMaker.exe C:\path\to\ImageFile.rti -q 90'
return
    <results>{process:execute($cmd, <options/>)}</results>

There is an article at the XQuery WikiBook about it.

Loren Cahlander
  • 1,257
  • 1
  • 10
  • 24
2

Unfortunately it is not possible to start an executable that is stored inside the database. The java API requires direct access to a file on the filesystem, and the '/db/....' path is not.

DiZzZz
  • 621
  • 3
  • 12