Code: Select all
sudo /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
sh /home/pi/domoticz/scripts/bash/deurbel.sh
Moderator: leecollings
Code: Select all
sudo /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
sh /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
os.execute("sh /home/pi/domoticz/scripts/bash/deurbel.sh &")
Code: Select all
sudo sh /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
pi@raspberrypi:~$ sudo sh /home/pi/domoticz/scripts/bash/deurbel.sh
Hallo
--2016-07-14 21:16:10-- http://192.168.2.1:8080/camsnapshot.jpg?idx=1
Connecting to 192.168.2.1:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 303356 (296K) [image/jpeg]
Saving to: ‘STDOUT’
- 100%[=====================>] 296.25K --.-KB/s in 0.008s
2016-07-14 21:16:11 (34.2 MB/s) - written to stdout [303356/303356]
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.10.0</center>
</body>
</html>
I don't understand what Jannl is saying. what should I change?jannl wrote:yes, that should work. (I assume the declaration of commandArray is present).
In the deurbel.sh script, all needed variables need to be declarared/initialised
Code: Select all
#!/bin/sh
echo "Hallo"
#SendMsgTo=$1
SendMsgTo=$TelegramChatId
#################################################################
IP="192.168.2.2" # IP address Camera
##########################################################
SnapFile=$TempFileDir"snapshot.jpg"
if ping -c 1 $IP > /dev/null ; then # if IPCAM is online then:
wget -O - http://192.168.2.1:8080/camsnapshot.jpg?idx=1 > $SnapFile
sleep 2
curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
else
curl --data 'chat_id='$SendMsgTo --data-urlencode 'text=IP-cam niet beschikbaar.' 'https://api.telegram.org/bot'$TelegramBotToken'/sendMessage'
fi
Code: Select all
sh /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
Code: Select all
echo curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
Code: Select all
sh /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
sudo /home/pi/domoticz/scripts/bash/deurbel.sh
Code: Select all
pi@raspberrypi:~$ sudo /home/pi/domoticz/scripts/bash/deurbel.sh
Hallo
--2016-07-14 21:43:51-- http://192.168.2.1:8080/camsnapshot.jpg?idx=1
Connecting to 192.168.2.1:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 299897 (293K) [image/jpeg]
Saving to: ‘STDOUT’
- 100%[==============================================================================>] 292.87K --.-KB/s in 0.01s
2016-07-14 21:43:52 (24.6 MB/s) - written to stdout [299897/299897]
curl -s -X POST https://api.telegram.org/bot/sendPhoto -F chat_id= -F caption=er wordt aangebeld -F [email protected]
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.10.0</center>
</body>
</html>
Jannl was right. With perfect help from jvdz my issue has been solved. The solution was to alter the script by declaring the variables in the top.jannl wrote:Are all the variables declared. They must be declared inside the proces space of the script.
For instance are you sure the scripts knows the value of $TelegramChatid?
Code: Select all
#!/bin/sh
TelegramBotToken="123456789:AAAAAAAAAAAAA_22222222222"
TempFileDir="/var/tmp/"
SendMsgTo="12345678"
IP="192.168.2.2" # IP address Camera
##########################################################
SnapFile=$TempFileDir"snapshot.jpg"
if ping -c 1 $IP > /dev/null ; then # if IPCAM is online then:
wget -O - http://192.168.2.1:8080/camsnapshot.jpg?idx=1 > $SnapFile
sleep 2
echo curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
else
curl --data 'chat_id='$SendMsgTo --data-urlencode 'text=IP-cam niet beschikbaar.' 'https://api.telegram.org/bot'$TelegramBotToken'/sendMessage'
fi
Users browsing this forum: Google [Bot] and 1 guest