Page 1 of 1

Lua string with quotes

Posted: Friday 25 November 2016 14:01
by remb0
I'm busy with my alarm script and want is as modular as possible, so I made a function:

Code: Select all

function My.PlaySound(msg)
    Debug='Y'
    if (Debug == 'Y') then print('>> Alarm speaks: '.. msg)     end
    os.execute ("sudo killall mplayer")
    os.execute ('sh /home/pi/domoticz/scripts/bash/Play_sound.sh' .. msg)
end
the Play_Sound script expects a parameter.. But I can't get msg as a variable.
I changed a lot with quotes etc, but don't get it working. the closes i got is that my speaker says" dotdot of M S G.
not the sentence in the variable msg.

What am I doing wrong?

Re: Lua string with quotes

Posted: Friday 25 November 2016 14:26
by remb0
found it!!!

os.execute ("sh /home/pi/domoticz/scripts/bash/Play_sound.sh '" .. msg .. "' ")