Action On Bash Scripts return -1

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
EricTheHalfABee
Posts: 2
Joined: Wednesday 04 May 2016 14:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Action On Bash Scripts return -1

Post by EricTheHalfABee »

Having trouble running an on action script. It started when the cpu temp from my raspberry stopped showing data in domoticz. So why not write a script to fix this manually and learn a bit of domoticz inner workings. To test and debug the script at first it was coupled to a switch to run at action on. That did not work as expected which send me on a this quest.

The script runs fine from a bash terminal and also when called by cron there is no problem. It's not the contents of the script, any script tried so far gives the same result. I read a lot of action on problems on the forum which gave me a lot of insight but none of them solves my problem. Since the error codes are consistent for all tried scripts there must be something I am overlooking. There are other ways to get this done, the original cpu temp script runs fine using cron, but I want to understand why action on script:// is not working.

This is a simple script that produces the same result.

Code: Select all

#!/bin/bash
echo "hello" >> /home/pi/domoticz/scripts/bash/test.log &
The script is located in:

Code: Select all

/home/pi/domoticz/scripts/bash/tems2.sh
It has the right file mode (755) and default pi account ownership. Hence no problem running it from a terminal or cron.
In the domoticz web interface it is configured in the on action of a switch.

Code: Select all

script:///home/pi/domoticz/scripts/bash/tems2.sh
When the switch is switched on the log says it is executing but returns an error. I looked but can't find what the return code means. The path and filename are correct.

Code: Select all

2016-05-04 12:38:58.899 User: Admin initiated a switch command
2016-05-04 12:38:58.901 (RFXtrx433 ) Lighting 2 (Schemerlamp Tafel)
2016-05-04 12:38:59.149 Executing script: /home/pi/domoticz/scripts/bash/tems2.sh
2016-05-04 12:38:59.149 Error: Error executing script command (/home/pi/domoticz/scripts/bash/tems2.sh). returned: -1 
Is there somebody here who knows what going wrong?
EricTheHalfABee
Posts: 2
Joined: Wednesday 04 May 2016 14:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Action On Bash Scripts return -1

Post by EricTheHalfABee »

Well guess I am glad I am not the only one puzzled by this one.

Since today is a holiday in the Netherlands I had some time to tinker with it.

Downloaded a new raspberry image, put it on a new sd, booted it, restored the data base, uploaded the script, flipped the switch and it just ran and created the file. What?

Same version of domoticz, new but same model sd, same raspberry pi and same database. The previous image ran for about nine months and accept for changes through the web interface of domoticz and auto-updating domoticz it was an unaltered default image.

I guess the problem is solved but I would still like to know what was wrong with the old (updated)image. So if somebody knows what causes the error or could point me to a direction where I could figure this out I would be grateful. I will keep the image with the problem for future testing.

On a side note:

While testing the script file was renamed. This of course requires you to rename it in the on action field. However if you do not rename it in the on action field (and probably off action as well) there will be nothing in the log file. I guess the absence of executing script... in the log is a clear indication. Still it would be nice if it mentioned if it could not find the file.
tullgren
Posts: 4
Joined: Monday 13 June 2016 15:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Action On Bash Scripts return -1

Post by tullgren »

Hi,

I have exactly the same problem.
But I'm not tempted to reinstall domoticz.
Does anyone have a solution? Or know what error -1 means?

//Regards Mikael
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Action On Bash Scripts return -1

Post by Egregius »

Could be that the -1 comes because no output is generated by the script.
Try adding a simple echo statement.
tullgren
Posts: 4
Joined: Monday 13 June 2016 15:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Action On Bash Scripts return -1

Post by tullgren »

Hi,

Thanks for your answer, but the script has worked before and now it not working any more.
Also the script will run i the ssh terminal whit no problem.

Thankful if you or someone else have more input to share.

//Mikael
tullgren
Posts: 4
Joined: Monday 13 June 2016 15:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Action On Bash Scripts return -1

Post by tullgren »

Hi,

I found a solution. When I tried to reboot the system from domoticz menu. I i notised in the log that the reboot gave the same error.
I changed the domoticz folder and my script folder to permission to 7777 and rebooted from the ssh terminal.

And it Works!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest