This is working great through a BASH script, but I am trying to get it to work through a LUA script.
Unfortunately I keep getting the error " 'then' expected near '1' " , but I do not know why.
The error is on line "20" ; if ping -c 1 $IPcam > /dev/null; then
Is there someone who can help me?
The script:
Code: Select all
--!/bin/sh
--=================================================================
--======================NETWORK SETTINGS==========================
IPcam="192.168.1.1" --IP address Camera
--=================================================================
--=====================TELEGRAM SETTINGS==========================
token="123456789:AABBcceeff87XkcggdHHCUiimJJ123q4567" --Token ID
chatid="91198712" --Chat ID
WebcamMessage="Webcam not online" --Message
AlertMessage="Movement in Garden?!" --Message
--=================================================================
commandArray={}
if otherdevices['Sun'] == 'Off' and
devicechanged['Sensor_Tuin'] == 'On' then
print('Motion detected in garden. Sending Message')
if ping -c 1 $IPcam > /dev/null ; then
--Send message through Telegram if PING successfull:
os.execute('curl "https://api.telegram.org/bot'..token..'/sendMessage?chat_id='..chatid..'&text='..AlertMessage..'" ')
--Send snapshot with Telegram when ping successful:
os.execute('wget http://127.0.0.1:8080/camsnapshot.jpg?idx=1 && sudo mv camsnapshot.jpg?idx=1 /var/tmp/snapshot.jpg')
--Wait for 5 seconds to be sure the snapshot has been copied
sleep 5
os.execute('curl -s -X POST "https://api.telegram.org/bot'..token..'/sendPhoto?chat_id='..chatid..'photo="@/var/tmp/snapshot.jpg"')
--Wait for 1 second before removing the snapshot
sleep 1
os.execute('/bin/rm /var/tmp/snapshot.jpg')
else
os.execute('curl "https://api.telegram.org/bot'..token..'/sendMessage?chat_id='..chatid..'&text='..WebcamMessage..'" ')
end
end
return commandArray
I am stuck...
