Page 1 of 1

Specific os.execute not working

Posted: Saturday 01 February 2020 15:42
by fvdp80
I'm trying to execute mplayer through Dzvents, but a specific command isn't working.

Code: Select all

os.execute ('amixer -D bluealsa sset "Trust SPK-14 - A2DP" 80%')
os.execute ('mplayer /home/pi/deurbel.mp3')
The first command works within Dzvents, but the second one isn't.
mplayer /home/pi/deurbel.mp3 does work as a direct command in putty.

Does anybody know what's wrong?

Re: Specific os.execute not working  [Solved]

Posted: Sunday 02 February 2020 13:02
by fvdp80
Solved my own issue.
The problem lies in the fact that mplayer can't be executed as root (due to alsa or pulse) and domoticz
executes all commands as root.
So the solution lies in executing the command as user pi with the following code:

Code: Select all

os.execute ("runuser -l pi -c \'mplayer /home/pi/deurbel.mp3'")

Re: Specific os.execute not working

Posted: Sunday 02 February 2020 14:27
by waaren
fvdp80 wrote: Sunday 02 February 2020 13:02 The problem lies in the fact that mplayer can't be executed as root (due to alsa or pulse) and domoticz
executes all commands as root.
Good that you solved it. What I understand is that domoticz executes all OS commands as the same user domoticz is executed with. So not necessarily root.