Lua os.execute problem

Hi there,

I have a problem with lua scripts of Orthanc.

What i'm trying to do is to monitor orthanc, each time a study is stable, export it as zip and run an external software that will handle processing on this zip (unzip and merge with other files etc).

I have no problem in the first part, I can monitor the stable study and get proper ZIP using a lua script.

My problem is when I want to call the external program.
I used that command :
os.execute ('java -jar C:\\Users\\salim\\Downloads\\OrthancEditor.jar')

I see a JVM being initialized but that stops the Lua scripts (i made a print line after the os.execute that is never reached) and even if the java program is inialized it didn't show it's GUI.

I even tried to run a bat script with just a echo function in it. Same problem I don't see the console showing.

I probably miss something ? how I can run an launch an external app in a Lua script ? Is there something special about Lua scripts in Orthanc ?

Best regards,



I probably miss something ? how I can run an launch an external app
in a Lua script ? Is there something special about Lua scripts in
Orthanc ?

Although I don't have an answer to that question yet, I suggest you
consider running a separate service that monitors the /changes resource
and triggers the execution of your code itself on every new stable

We use this approach in many projects and can report it does work very
well in practice.

Currently you need to monitor the /changes resource via polling, but
feel free to suggest alternate mechanisms in the issue tracker if you'd
like (e.g. SSE, WebSocket, Web Push, ...).

This way you can also use your language of choice immediately.

Hi Thibaut,

I fact to continue in my project I made my Java application to monitor the folder where the lua scripts export the dicom ZIP, that way each time a zip is exported my app see the file-event and make the processing i need.
So for my side I can continue on my project.

The strange thing is that I have no problem with command like “mkdir” in Os.execute but external app seems to run in sort of thread that never reach the GUI or something like that.
Even stranger, when I try to erase the Orthanc Log file, windows tells me that the log file is locked by the external app I called.
I tried to make a bat file that run the executable in a separate thread but again with no success, the bat is OK a really run my app separately from the console but when called by lua script the software still stay invisible.

Sounds like a thread bug…
At least I can fly for my project but It would be interesting to see for future where the problem comes from.

Best regards,



I re-post here an (unverified) answer provided from Dr Sherif that was blocked by Google Groups:

You have to separate the command i two lines like this:

local comm = (‘java -jar C:\Users\salim\Downloads\OrthancEditor.jar’)
local res1= os.execute(comm)
print(‘ok-’ … res1)

Unfortunatly it didn't solve my problem