Rule Script bash not working as expected

I have a bash script that sets Openhab status on some items when launched outside openhab that is working fine

2015-10-06 10:10:52 - Active_Calling state updated to “201”
2015-10-06 10:10:52 - Active_Called state updated to “999”

When running as a rule

ule “Call”
Item Asterisk_Ring changed

      if(Asterisk_Ring.state == ON)

     executeCommandLine("bash /etc/openhab/configurations/rules/")

      if(Asterisk_Ring.state == OFF)
    executeCommandLine(" bash /etc/openhab/configurations/rules/")


2015-10-06 10:11:28 - Asterisk_Ring received command ON
2015-10-06 10:11:28 - Active_Calling state updated to
2015-10-06 10:11:28 - Active_Called state updated to

It is set to blank

curl command is as follows

curl --header ‘Content-Type: text/plain’ --request PUT --data “$numbercalling” “

Why inside openhab does not set correctly and running outside it worked fine?

I get called /calling number from Asterisk and setting to an Item


Openhab.log is normal and shows:

2015-10-06 10:11:28.588 [INFO ] [] - executed commandLine ‘bash /etc/openhab/configurations/rules/’
2015-10-06 10:11:36.247 [INFO ] [] - executed commandLine ’ bash /etc/openhab/configurations/rules/’

If your openhab and script is on the same machine could you maybe replace the IP with localhost?



I tried that but same issue

curl --header ‘Content-Type: text/plain’ --request PUT --data “$numbercalling” http://localhost:8080/rest/items/Active_Calling/state/
curl --header ‘Content-Type: text/plain’ --request PUT --data “$numbercalled” http://localhost:8080/rest/items/Active_Called/state/

2015-10-06 10:41:47 - Asterisk_Ring received command OFF
2015-10-06 10:41:48 - Active_Calling received command -
2015-10-06 10:41:48 - Active_Called received command -

Running outside

2015-10-06 10:43:24 - Active_Calling state updated to “201”
2015-10-06 10:43:24 - Active_Called state updated to “999”

Running outside openhab rules , script sets correctly data

Maybe i could do in other way?

Have you tried running openhab as root to check it’s not a permissions issue?

Yes. Its running as root


have you tried piping the output of the bash script to a log file so you can see what’s happening when it’s triggered?