Page 1 of 1

OS.Execute - running for more than 10 seconds

Posted: Friday 08 September 2017 13:11
by henning
Hello

I try to getting this "speedup" to work on a Windows installation
http://easydomoticz.com/forum/viewtopic ... 55b841a5ce

I can see the problem is the "os.execute" line.


If i make a Lua Script with

**
curl = "C:\\Domoticz\\Curl\\curl.exe " -- don't forgot the final space
os.execute(curl..'"http://127.0.0.1:8080/json.htm?type=com ... itchcmd=On" &')

**

The log says - Error: EventSystem: Warning!, lua script test2 has been running for more than 10 seconds

but after the 10 sec - the switch 2 is turning on.. So it look like domoticz waiting on the os.execute to finish

I have read in another thread that i have to add "&" in the end (see my example), but it dont make any different. Maybe it only is a solution for linux..


Any try to use os.execute on windows..?

Re: OS.Execute - running for more than 10 seconds

Posted: Friday 08 September 2017 15:07
by Logread
My first suggestion would be to avoid using os.execute() / curl altogether and just use:

Code: Select all

table.insert(commandArray, { ["OpenURL"] = <your url>})
but action will only take place when the lua script is finished... otherwise may be add "cmd" before the actual curl command to run the command in a separate shell (I did not test...), but not sure you can control the sequence very well as this would become asynchronous.

Re: OS.Execute - running for more than 10 seconds

Posted: Friday 08 September 2017 18:21
by zak45
On windows you can use start command, this will execute your cmd in another process and go back to the eventsystem to release it.
e.g.
start cmd /c C:\Domoticz\plugins\WanIPspeed\plugin.cmd

Re: OS.Execute - running for more than 10 seconds

Posted: Friday 08 September 2017 22:58
by henning
Why not use os.execute..? Is it only for Linux..?

I Will try the Start command, and see how it works.
Buf if some One know how i can use os.execute and Dont have to wait for the command to finish before process - Will it be realy Nice..

Re: OS.Execute - running for more than 10 seconds

Posted: Friday 08 September 2017 23:28
by zak45
mycmd=os.execute('start cmd /c c:/temp/plugin.cmd')

Re: OS.Execute - running for more than 10 seconds

Posted: Saturday 09 September 2017 8:03
by Logread
henning wrote: Friday 08 September 2017 22:58 Why not use os.execute..? Is it only for Linux..?
It makes your script platform dependant... that is fine if this script is only for your own use, but should be avoided if possible if you intend to publish your script, since the script will require changes depending on the platform (windows, linux rapsberry, linux synology, etc...). That's why I recommended using the commandArray["OpenURL"] construct

Re: OS.Execute - running for more than 10 seconds

Posted: Monday 11 September 2017 8:24
by henning
I made it work with "mycmd=os.execute('start cmd /c c:/temp/plugin.cmd')"- but see no performance improvements compared to using blocky.

But thanks for the help :)

Re: OS.Execute - running for more than 10 seconds

Posted: Sunday 03 January 2021 18:36
by Quest24
I had the same problem on windows 10

I run a domoticz remote application on this windows 10 machine for controlling my audio

I run a command to control the volume on this machine from my dommoticz running on a pi

I had to set the security settings of the execution file for gloabal use.

This is my lua code in domoticz running on the windows 10 machine

Code: Select all

commandArray = {}

  if (devicechanged['Windows10-Vol'] ) then
 
     local volume = tonumber(otherdevices_svalues['Windows10-Vol'])
     local volset = volume * 65535 / 100
     
     print (volset)
    
     os.execute('C:\\programs\\nircmd.exe setsysvolume ' ..volset )
  
   end

return commandArray