Page 1 of 1

issue with os.execute

Posted: Sunday 16 January 2022 18:39
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

Re: issue with os.execute

Posted: Sunday 16 January 2022 19:24
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

Re: issue with os.execute

Posted: Monday 17 January 2022 20:39
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.

Re: issue with os.execute

Posted: Monday 17 January 2022 21:39
by waltervl
Great, have fun!