Python script parameter in ' '

Hi,
I wrote a simple rule:

rule "Run"
when
    Item Run received command ON
then
    val String answer = executeCommandLine("python3 /etc/openhab2/scripts/openstuder-examples-python/cli/sicli.py localhost 'read xcom.xt1.3000'", 5000)
    logInfo("Result=", answer)
end

Answer should be a string like:
xcom.xt1.3000 = 50.625

But in openhab.log I can see a error message:

2023-06-04 16:59:39.255 [INFO ] [lipse.smarthome.model.script.Result=] - *** Unknown syntax: "read xcom.xt1.3000"

Correct syntax with using ’ ’ please ?
Thanks.

  • Platform information:
    • Hardware: Rpi3
    • OS: Raspbian Bullseye
    • Java Runtime Environment: openjdk version “1.8.0_312”
    • openHAB version: 2.15 last

OH 2.5 is really old now. IIRC you need to replace spaces between command line arguments with @@.

Beyond that, the error is coming from your Python script so :person_shrugging: . Add some logging to your Python script, modify it to handle the read xcom.xt1.3000 as a single command line argument (that’s what happens when you pass it in quotes like that).

Try running it with those arguments from the command line using the openhab user.

sudo -u openhab python3 /etc/openhab2/scripts/openstuder-examples-python/cli/sicli.py localhost 'read xcom.xt1.3000'

Thanks Rich.
Result:

sudo -u openhab python3 /etc/openhab2/scripts/openstuder-examples-python/cli/sicli.py localhost 'read xcom.xt1.3000'
xcom.xt1.3000 = 50.53125

Same with @@ (chown root:root but chmod=777)
val String answer = executeCommandLine(“/etc/openhab2/scripts/openstuder-examples-python/cli/./sicli@@localhost@@‘read xcom.xt1.3000’”, 5000)

[INFO ] [lipse.smarthome.model.script.Result=] - *** Unknown syntax: “read xcom.xt1.3000”

Maybe I will try to modify calling python script with params without ’ ’

No problem if parameter inside ’ ’ is only one string, e.g.

 val String answer = executeCommandLine("python3 /etc/openhab2/scripts/openstuder-examples-python/cli/sicli localhost 'info'", 5000)
    logInfo("Result=", answer)

Answer:

2023-06-05 10:27:20.985 [INFO ] [lipse.smarthome.model.script.Result=] - client state: CONNECTED
gateway version: 0.3.3
access level: QUALIFIED_SERVICE_PERSONNEL

Eclipse has problem with points inside string e.g.‘xcom.xt1.3000’

Hi, have always attention, that you are using FULL PATHS in python scripts !!!