Can not get bash script to work

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Can not get bash script to work

Post 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.
User avatar
jvdz
Posts: 2266
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Can not get bash script to work

Post by jvdz »

How do you start it from Domoticz?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Can not get bash script to work

Post 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.
User avatar
jvdz
Posts: 2266
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Can not get bash script to work

Post by jvdz »

What did you put in the On action that didn't work?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Can not get bash script to work

Post by olskar »

script:///home/pi/domoticz/scripts/posten.sh
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Can not get bash script to work

Post 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
User avatar
jvdz
Posts: 2266
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Can not get bash script to work

Post by jvdz »

You did change the file properties with chmod +x posten.sh to allow it to be executed?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Can not get bash script to work

Post by olskar »

jvdz wrote:You did change the file properties with chmod +x posten.sh to allow it to be executed?

Jos
Yes
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Can not get bash script to work

Post 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.
User avatar
jvdz
Posts: 2266
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Can not get bash script to work

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Can not get bash script to work

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest