OH3 (openhabianpi): executeCommandLine returns always with empty result for python2 commands

I switched to openhab 3 a few days ago. Now I realize that my rules with excecuteCommandLine are not working anymore. I saw that the syntax changed and I corrected the syntax according to the documentation. The strange thing is that “standard shell command” like “ls” or “pwd” are excecuted fine and I see the returned result. If I call a python script, its not excetuted at all and I also don’t see an error in the log.

Here my symplified rule. Only with pythin version output:

val telegramAction = getActions("telegram","telegram:telegramBot:mybot")

// works fine!
var result = executeCommandLine(Duration.ofSeconds(50),"pwd")
telegramAction.sendTelegram("test: "+result)

//does not work!!:
result = executeCommandLine(Duration.ofSeconds(50),"/usr/bin/python", "-V")
telegramAction.sendTelegram("test2: "+result)

In telegram I see the following.

test: /var/lib/openhab
test2:

Python is not called! No errors in log.

Does anybody can give me a hint where I should continue searching. In the forum I saw similar issues with sudo commands but not with such standard thinks…

Update 14:50: Python3 works! Strange… What can be the difference?

val telegramAction = getActions("telegram","telegram:telegramBot:mybot")

//Python3 works also!!:
result = executeCommandLine(Duration.ofSeconds(50),"python3", "-V")
telegramAction.sendTelegram("test2: "+result)

In telegram I see the following.

test2: Python 3.7.3

gitHub issie create:

I think I found the root cause. If the command returns something != 0 the output is not cached in the result variable.
python3 seams to return by default 0. python2 not.

I can execute now the following script in python3:

test.py:

print("Hallo World")

“Hello World” is catched in the result variable. In python2 result is “null”

The following script work with both: python3 and python2

test2.py:

print("Hallo World")
sys.exit(0)

Is this a bug or a feature…!? I think I will create an issue in gitHub!?

In the python repo? 'cause that’s not a defect in OH.

You did not get the point, I think.
Sorry for the python example code. Makes it just easier to reproduce.

Even if a script returns an “error code” its useful to see the result and not an empty string and and empty log. You are blind in cases of an error.

In OH2 ist also worked different and the output was catched in the result variable.