Domoticz not executing script, putty is.

Moderator: leecollings

fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Domoticz not executing script, putty is.

Post by fransiefrans »

My Domoticz won't execute any sh script. in Putty the snapshots are send to telegram. When I try the same script with an on action I only see:

Code: Select all

Executing script: /home/pi/domoticz/scripts/bash/deurbel.sh
But no snapshots is send.

im using the following at on action: script:///home/pi/domoticz/scripts/bash/deurbel.sh
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Domoticz not executing script, putty is.

Post by emme »

script base path is /home/pi/domoticz/scripts so I think you should only put script://bash/deurbel.sh
The most dangerous phrase in any language is:
"We always done this way"
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Domoticz not executing script, putty is.

Post by Egregius »

What are the permissions and owner of the file?
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

According to the logging, the scripts seems to be executed. Complete patch should not be the problem.

I think some path (or environment) settings in the script are not correct, so something (binary or setting) cannot be found by the script . When I am correct, the script is executed as user root (the user Domoticz is running under).
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

Im using the following script:

Code: Select all

#!/bin/sh
#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
I used the same script on an other domoticz before and it used to work. But since I did a fresh install the script is not working in domoticz.

The rights are 777
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

Where are $TelegramChatId and $TempFileDir declared?
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

I think in the domoticzdata.sh
The script is working in putty so I assume the chat id and the tempfiledir are ok

Or should I change both to a direct path?
oliviers
Posts: 73
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Paris area, France
Contact:

Re: Domoticz not executing script, putty is.

Post by oliviers »

Maybe it's because it's a long-running script (ping + "sleep 2" + wget + curl ...), which domoticz doesn't like ....
Try to launch it in background via an intermediate script:

#!/bin/sh
/home/pi/domoticz/scripts/bash/deurbel.sh &
Paris area
Raspberry Pi 4 - RFXComm 433 - IrTrans - Zwave
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

I will give that a try later this evening.

Thanks
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

unfortunately the smaller script is giving me the same results. In putty fine in domoticz only executing in the log.
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

I've never made a lua script before. I suppose it's possible to trigger the deurbel.sh when deurbel=on. How should I make the Lua script?
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

My doorbell script is a lua script that calls a shellscript (os.execute with an &) that runs in the background.
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

Could u show me the script?
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

I will post it here tonight when I am at home
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

Thank you
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

The lua script

Code: Select all

-- Do stuff when doorbell rings

--print('Doorbell pressed')

t1 = os.date("*t")

-- In the evening set hall light on for 1 minute
if (timeofday['Nighttime']) then
        commandArray[1]={['LampGangOnder']='On FOR 1'}
end
if  (otherdevices['TweedeBelAan'] == 'On') then
        print('Ring second bell')
        commandArray[2]={['TweedeBel']='On'}
end
--Do not ring second bell at night
--save snapshot 
os.execute("wget \"http://192.168.1.5:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=voordeur&pwd=voordeur\" -O /home/pi/domoticz/www/images/voordeur.jpg;chown pi:pi /home/pi/domoticz/www/images/voordeur.jpg")
-- Send e-mail & notification when doorbell and nobody at home and send image if we install a camera sometime
if (otherdevices['IemandThuis']=='Off') then
        body="Hallo,<br><br>Aangebeld om: " .. t1.hour .. ":" .. t1.min .. "<br><br>Groetjes"
        --commandArray[3]={['SendEmail']='Iemand aan de deur#' .. body .. '#[email protected]'}
        commandArray[4]={['SendNotification']='Iemand aan de deur#' .. body ..'#0' }
        -- send mail
        os.execute("/home/pi/domoticz/scripts/stuurmail.sh &")
else
	-- blink light for additional attention
        if ( otherdevices['Lamp bijzettafel'] == 'Off' ) then
                os.execute("/home/pi/domoticz/scripts/knipper_eerst_aan.sh &")
        else
                os.execute("/home/pi/domoticz/scripts/knipper_eerst_uit.sh &")
        end
end

The actual mail script (uses muttrc)

Code: Select all

#!/bin/sh
#Mail picture
#echo "Start" > /home/pi/domoticz/scripts/mutt_log.txt
export MAIL=/var/mail/root
export MAILCHECK=60
export PATH=$PATH:usr/local/sbin
export [email protected]
export HOME=/root
mutt -s Voordeur [email protected] -a /home/pi/domoticz/www/images/voordeur.jpg < /home/pi/domoticz/scripts/voordeur_mailbody.txt >> /home/pi/domoticz/scripts/mutt_log.txt
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

Can i write te lua like this?

Code: Select all

-- Do stuff when doorbell rings

--print('Doorbell pressed')

if (otherdevices['dummy']=='On') then
       os.execute("/home/pi/domoticz/scripts/bash/deurbel.sh &")
end

return commandArray
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

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
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Domoticz not executing script, putty is.

Post by fransiefrans »

All of a sudden no bash scripts are working.. not even in putty.
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Domoticz not executing script, putty is.

Post by jannl »

I suppose you get an error message?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest