Specific os.execute not working  [Solved]

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

Moderator: leecollings

Post Reply
fvdp80
Posts: 70
Joined: Tuesday 14 August 2018 8:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10303
Contact:

Specific os.execute not working

Post 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?
fvdp80
Posts: 70
Joined: Tuesday 14 August 2018 8:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10303
Contact:

Re: Specific os.execute not working  [Solved]

Post 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'")
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Specific os.execute not working

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest