Run exec with parameter (again...)

I’m trying my hand at exec binding but I can’t get it to work. I have searched both in the exec documentation and here in the forum, but i can’t really figure out the entries. What have I missed, what am I doing wrong?

What I have done:

  1. created an exec thing with the command:
    /bin/echo %2$s

  2. created one channel each for run (switch), input (string) and output (string)

  3. entered the command in the whitelist:
    /bin/echo %2$s

  4. created a blockly script, which set the input value with TEST and then send the command:


the message appears in the log:

2023-03-13 19:46:40.924 [WARN ] [ng.exec.internal.handler.ExecHandler] - An exception occurred while formatting the command line '/bin/echo %2$s' with the current time 'Mon Mar 13 19:46:40 CET 2023' and input value 'null': Format specifier '%2$s'

OpenHab is running version 3.4.1 on a RaspberryPi

What are the rest of the exec binding Thing’s configs? Click on the code tab and paste that. How it behaves depends on how it’s configured.

Note, the way it’s supposed to work is you sendCommand to the Input Channel Item when you want to trigger the script to run. The binding will update the Running Channel Switch Item to show that the script is running.

You only sendCommand to the Running Channel Item when you are not using the Input Channel.

It’s subtle but covered in the docs:

  • the current (or last) command to the input channel (see below, example: %2$s)

I added the emphasis.

The binding never sees updates so you must send command.

here is the things config:

UID: exec:command:3917d986ca
label: VectorAlert
thingTypeUID: exec:command
  transform: REGEX((.*))
  interval: 0
  autorun: false
  command: /bin/echo %2$s
  timeout: 15
location: Wohnzimmer

I created the channels without any changes by simply using “add link to item” and “create new item”.

ah, it’s working now! thank you for the hint! :smiley: