Unable to execute batch file with spaces in arguments
Posted: Thursday 01 February 2018 15:30
I'm running Domoticz in Windows and try the following code to send Pushbullet notification to multiple users:
prints will show this: LUA: "C:\Program Files (x86)\Domoticz\scripts\bash\pushbullet.bat" this works
print will show this: LUA: & 'C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat' "this does" "not"
print will show this: LUA: "C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat" '"this does" "not"'
The pushbullet.bat takes two argument and if arguments are surrounded by " ", it will also work with spaces. And copy pasting either of these two into PowerShell works:
Suggestions?
Code: Select all
local title = 'this '
local message = 'works'
local tit_msg = title..message
local path = [["C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat" ]]
local combined = path..tit_msg
os.execute(combined) Code: Select all
local title2 = '"this does" '
local message2 = '"not"'
local tit_msg2 = title2..message2
local path2 = [[& 'C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat' ]]
local combined2 = path2..tit_msg2
os.execute(combined2)Code: Select all
local title3 = [['"this does" ]]
local message3 = [["not"']]
local tit_msg3 = title3..message3
local path3 = [["C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat" ]]
local combined3 = path3..tit_msg3
os.execute(combined3)The pushbullet.bat takes two argument and if arguments are surrounded by " ", it will also work with spaces. And copy pasting either of these two into PowerShell works:
Code: Select all
& 'C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat' "this does" "not"Code: Select all
start "C:\Program Files (x86)\Domoticz\scripts\batch\pushbullet.bat" '"this does" "not"'