Page 1 of 1
Can not get bash script to work
Posted: Friday 07 July 2017 18:09
by olskar
Hello,
In ~/domoticz/scripts I have placed a script named posten.sh
The script contains this
Code: Select all
#!/bin/bash
castnow --quiet --address 192.168.1.185 /home/pi/cast/Post.mp3
I can run the command fine from terminal over ssh, but no way of getting it to work in domoticz, what could be wrong? I have made the script runnable.
Re: Can not get bash script to work
Posted: Friday 07 July 2017 18:13
by jvdz
How do you start it from Domoticz?
Jos
Re: Can not get bash script to work
Posted: Friday 07 July 2017 18:15
by olskar
jvdz wrote:How do you start it from Domoticz?
Jos
I have tried different ways. I want it to run when a switch turns on. I tried the settings for what to do on on/off in the switch-settings, i have tried blocky and tried lua.
Re: Can not get bash script to work
Posted: Friday 07 July 2017 18:44
by jvdz
What did you put in the On action that didn't work?
Jos
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:10
by olskar
script:///home/pi/domoticz/scripts/posten.sh
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:15
by olskar
I see this in log:
Executing script: /home/pi/domoticz/scripts/posten.sh
But still doesnt work, the script is for sending a Sound to my Google home
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:15
by jvdz
You did change the file properties with chmod +x posten.sh to allow it to be executed?
Jos
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:16
by olskar
jvdz wrote:You did change the file properties with chmod +x posten.sh to allow it to be executed?
Jos
Yes
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:21
by olskar
Can it be that domoticz somehow runs the script to quickly and ends it before getting a chanse to make a sound? It takes a while to run.
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:27
by jvdz
You don't want to run anything that takes long with the event systems as it is single threaded meaning it will hold up any actions until it is finished.
Also believe the 10 seconds limit is enforced for these type of script. You could add some logging to the script to see if anything is going worn with it.
Something like:
Code: Select all
#!/bin/bash
echo starting castnow >> /var/log/test.log
castnow --quiet --address 192.168.1.185 /home/pi/cast/Post.mp3 >> /var/log/test.log
echo castnow ended >> /var/log/test.log
Also the domoticz.log should so a log entry for the start of your script
Jos
Re: Can not get bash script to work
Posted: Friday 07 July 2017 19:35
by olskar
Hm the problem seems to be perhaps that castnow is in fact a link to a index.js meant to be run with node/npm
pi@raspberrypi:~/.nvm/versions/node/v8.1.0/bin $ ls -l
total 31736
lrwxrwxrwx 1 pi pi 36 Jun 10 22:14 castnow -> ../lib/node_modules/castnow/index.js