Can someone please help explain why this script won't run in Domoticz?

All kinds of 'OS' scripts

Moderator: leecollings

User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

I have a very simple script that runs perfectly fine from the pi user in a terminal window, but when I try to place the command into a bash script and fire it from an On Action in Domoticz, all I get is 'Executing script' in the log, and nothing happens.

/home/pi/domoticz/scripts/skyhd_pause.sh contains:

Code: Select all

#!/bin/bash
sky-remote-cli 192.168.0.109 pause &
When I run

Code: Select all

sky-remote-cli 192.168.0.109 pause
in an SSH window after logging in as user pi, the script runs fine and my Sky box pauses.

However, I've created a dummy switch and entered script://skyhd_pause.sh in the On Action, the log file says:

2017-05-25 20:23:37.996 Executing script: /home/pi/domoticz/scripts/skyhd_pause.sh

But nothing happens, no error nothing.

What am I doing wrong?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by waaren »

Have you tried adding an extra forward / ?
like script:///
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by Egregius »

If you add a third slash you must specify the full path:

Code: Select all

script:///home/pi/domoticz/scripts/skyhd_pause.sh
Add a simple logline to your script, something like:

Code: Select all

#!/bin/bash
NOW=$(date +"%Y-%m-%d")
LOGFILE=/home/pi/sky-remote.$NOW.log
echo  $(date +"%Y-%m-%d %H:%M:%S") sky-remote pause | tee -a $LOGFILE
sky-remote-cli 192.168.0.109 pause &
That should create a logfile (every day a new file) and add the timestamp of execution to it.

Personnaly I would set the command as an option in the command line:

Code: Select all

#!/bin/bash
NOW=$(date +"%Y-%m-%d")
LOGFILE=/home/pi/sky-remote.$NOW.log
COMMAND="$1"
echo  $(date +"%Y-%m-%d %H:%M:%S") sky-remote $COMMAND | tee -a $LOGFILE
sky-remote-cli 192.168.0.109 $COMMAND &
And then use this in domoticz:

Code: Select all

script:///home/pi/domoticz/scripts/skyhd_pause.sh pause
That way you can use one script for other commands to, I assume you have other commands to sent as well?
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

Okay, so I don't need a third slash, as my script is in the correct script folder. If the path to the script was incorrect, I wouldn't see

Code: Select all

Executing script
in the log would I?

I don't necessarily want to change the script itself in terms of the command, as I only use the pause command, so this is fine for me.

It's more the case that I Want to find out why it works when I execute the command directly in the terminal, but nothing happens from DOmoticz.
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

waaren wrote:Have you tried adding an extra forward / ?
like script:///
Since my script location is in the default script folder as recognised by Domoticz, I don't need to have three slashes.

The third slash would only indicate that I'm specifying a path starting from the root, which I am not.
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: Can someone please help explain why this script won't run in Domoticz?

Post by emme »

can you list the rights of the file? (ls -l )

normally this should not be an issue.... but I have the same problem with a .sh script with I had to issue a
sudo chmod +X ircommand.sh
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

Sure, currently showing as

Code: Select all

-rwxr-xr-x
which seems to be the same as the standard

Code: Select all

update_domoticz
script, and user/group is set to pi pi.

I do know, the permissions are set in FileZilla for this file as 0755, if that helps?
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: Can someone please help explain why this script won't run in Domoticz?

Post by emme »

where the file sky-remote-cli is located?

try to enter its full path in the script
eg. if it is stored in /usr/bin
/usr/bin/sky-remote-cli 192.168.0.109 pause
ciao
M
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: Can someone please help explain why this script won't run in Domoticz?

Post by Egregius »

Was the timestamp written in the logfile?
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

emme wrote:where the file sky-remote-cli is located?

try to enter its full path in the script
eg. if it is stored in /usr/bin
/usr/bin/sky-remote-cli 192.168.0.109 pause
ciao
M
I've never had to do that before when it previously worked.

Besides I have no idea where the actual files are, I've never seen them.


Sent from my iPhone using Tapatalk
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by Egregius »

With this you can find the location:

Code: Select all

sudo find / -name "sky-remote-cli"
But why don't you add the logfile line? Then at least you know it the script is executed or not.
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

2017-05-27 07:49:41.509 Executing script: /home/pi/domoticz/scripts/skyhd_pause.sh
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by Egregius »

That's the domoticz logfile, not the one created by the script.
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

In which case you'll need to explain how I view this log file, because I've never heard of it, or ever seen it before.
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

Hmm that seems a bit unnecessary as this has worked fine in the past without having to add anything extra to the script.

Could it just be a user/group permissions issue? Maybe I need to change ownership of the file so that Domoticz can execute it?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by Egregius »

Asking for help but not accepting it?
Good luck with it.
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

What I'm saying is, there must be something simple here, as this has worked fine before doing the exact same thing, but now it's not.
User avatar
jvdz
Posts: 2335
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by jvdz »

So help us to help yourself and add some debugging statements in the script to understand what is going on. ;-)
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can someone please help explain why this script won't run in Domoticz?

Post by leecollings »

Hey, so the log file that was created contains one line:

2017-05-29 17:56:02 sky-remote pause

Looks like the command is being executed then?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest