Issue with exec binding in OH 2.5.2

There is a new requirement for the exec bindging in OH 2.5.2 for a whitelist. I followed the instructions in the binding documentation, but I’m still getting an error.

2020-03-07 14:33:34.234 [WARN ] [ng.exec.internal.handler.ExecHandler] - Tried to execute 'c:\apcupsd\bin\apcaccess -u', but it is not contained in whitelist.

My file exec.whitelist looks like this:

c:\apcupsd\bin\apcaccess -u

Perhaps I misunderstood what was meant by this:

Allowed commands need to be added to the misc/exec.whitelist file in the configuration directory

I placed the file at C:\openHAB2\conf\misc\exec.whitelist

Platform information:

  • Hardware: Intel Atom x5, 4gb
  • OS: Windows 10
  • Java Runtime Environment: (Zulu (build 1.8.0_222-b10)
  • openHAB version: 2.5.2

lots of topics about this lately, quick search on this forum

Thanks @Andrew_Rowe. I fat-fingered my search and didn’t see all that before. Sorry for the noise.

1 Like

no worries, come back if you can’t get it to work
seems like most folks have an issue with incorrect encoding or saving the file in a different editor to fix LF CR end of line stuff

Yeah, still having trouble.

I trued grabbing the latest jar file for exec, from here (I tried the latest one for 2.5.3, and had the same issue as below, so I tried this one since it’s the newest one I could find for 2.5.2.)

It’s throwing an error with a long stack trace, starting with

2020-03-07 16:18:15.378 [ERROR] [org.openhab.binding.exec            ] - bundle org.openhab.binding.exec: (258)[org.openhab.binding.exec.internal.ExecHandlerFactory(264)] :  Error during instantiation of the implementation object
java.lang.IllegalArgumentException: argument type mismatch

Interesting what you said about line endings … I’m in Windoze using VS Code. I’ll look into that. The “touch” fix isn’t helping me. I’m wondering if it’s an issue with the backslashed windows path? Maybe messing up a string comparison?

ummm from what I’ve read you need to enter the commands exactly as they would run in the console (terminal) but the line end thing is usually file made on windows (or with windows editor) then run on Pi but this is OpenHAB installed on Windows correct? But hidden characters at the end of the lines such as carriage returns or new line characters (which are hidden usually) mess things up
Have you ever used notepad++
with it you can see the hidden character and there is a windows version (free software btw)
also spaces at line ends have caused some problems I think
Anyhow… are you sure the bidding is loaded and running, the error almost looks like the binding failing to load… not sure
Also, having to touch the file after start up as been fix already in newest builds

Try dropping the c: from your entry if it is executing from c drive anyway.

Thanks @Andrew_Rowe and @Bruce_Osborne.

I sorted out the line ending thing. Honestly, I’m not sure if that was it, but I completely replaced the file and it seems to be OK now. I can edit it from VS Code, and it doesn’t seem to matter if my line endings are set to CRLF or just LF. And yes, I’m runing on Windows.

I have had no luck installing the latest jar file; still getting lots of errors in the log. I just wish I didn’t have to remember to touch that whitelist file every time i restart OH.

Thanks again for the help.

1 Like

A simple way I used on my installation to allow everything I have:

# create dir in case it does not exist
mkdir -p /etc/openhab2/misc

# populate whitelist
grep exec /etc/openhab2/things/* |
grep command= |
sed 's/.*command="\(.*\)".*/\1/' > /etc/openhab2/misc/exec.whitelist

# make sure openhab owns the file
chown -R openhab:openhab /etc/openhab2/misc/

Works if you have all your exec things configured in *.things-files and exec like this:

Thing exec:command:xxx [ command="command_with args_or_formatter %2$s", interval=60, timeout=1, autorun=false ]

Can be used to automatically update the whitelist, too.

1 Like