issue with os.execute

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

issue with os.execute

Post by usky73 »

Hi all

I am reusing a script un dz.vents but facing issue with os.execute that is not working.
The command is working well in a terminal.
The domoticz is installed on a raspbery under buster.

the instruction is :

Code: Select all

command = "/usr/bin/python3 "..scriptPython.." "..credentials.." "..fichierTemp.." &"
domoticz.log(command)
os.execute(command)
the command print in the log is : "/usr/bin/python3 /home/pi/domoticz/scripts/python/MyRenault.py /home/pi/domoticz/scripts/python/credentials.json /var/tmp/zoe.txt &"

What could be the issue ?

Thanks for your support
User avatar
waltervl
Posts: 5865
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: issue with os.execute

Post by waltervl »

Try to run the command in a shell as root (eg with sudo) as Domoticz will do that too.

BTW it's better to use domoticz.executeShellCommand() instead of os.execute() see wiki:
https://www.domoticz.com/wiki/DzVents:_ ... _execution
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

Re: issue with os.execute

Post by usky73 »

thanks a lot, it looks interesting. I will investigate.

UPDATED : Problem solved thanks to your 2 advices.
1- the issue becomes visible by using sudo in the terminal. I was able to see that it was missing a library for root.
2- the asynch lethod is much better !

Thanks again for your help.
User avatar
waltervl
Posts: 5865
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: issue with os.execute

Post by waltervl »

Great, have fun!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest