Page 1 of 2
Can someone please help explain why this script won't run in Domoticz?
Posted: Thursday 25 May 2017 22:05
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?
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 0:22
by waaren
Have you tried adding an extra forward / ?
like script:///
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 6:16
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?
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 15:09
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
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.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 17:04
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.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 17:08
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
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 17:17
by leecollings
Sure, currently showing as
which seems to be the same as the standard
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?
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Friday 26 May 2017 17:37
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
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 6:38
by Egregius
Was the timestamp written in the logfile?
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 6:57
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
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 7:14
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.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 9:31
by leecollings
2017-05-27 07:49:41.509 Executing script: /home/pi/domoticz/scripts/skyhd_pause.sh
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 11:36
by Egregius
That's the domoticz logfile, not the one created by the script.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 11:57
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.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 13:05
by Egregius
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 13:43
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?
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 14:13
by Egregius
Asking for help but not accepting it?
Good luck with it.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 14:17
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.
Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Saturday 27 May 2017 14:18
by jvdz
So help us to help yourself and add some debugging statements in the script to understand what is going on.

Re: Can someone please help explain why this script won't run in Domoticz?
Posted: Tuesday 30 May 2017 18:54
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?