OS.Execute - running for more than 10 seconds

Moderator: leecollings

Post Reply
henning
Posts: 3
Joined: Friday 08 September 2017 12:57
Target OS: Windows
Domoticz version:
Contact:

OS.Execute - running for more than 10 seconds

Post 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..?
Logread
Posts: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post 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.
zak45
Posts: 953
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

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

Post 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
henning
Posts: 3
Joined: Friday 08 September 2017 12:57
Target OS: Windows
Domoticz version:
Contact:

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

Post 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..
zak45
Posts: 953
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

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

Post by zak45 »

mycmd=os.execute('start cmd /c c:/temp/plugin.cmd')
Logread
Posts: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post 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
henning
Posts: 3
Joined: Friday 08 September 2017 12:57
Target OS: Windows
Domoticz version:
Contact:

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

Post 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 :)
Quest24
Posts: 9
Joined: Tuesday 17 November 2020 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024-2
Contact:

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest