Need some help with exec and CAT

Hi,

I need some help to read my energy meter

I have following thing

Thing exec:command:zaehler [command="cat /dev/ttyUSB0 | xxd  -l204 >z1.txt", interval=15, timeout=5, autorun=false]

The energy meter is on the USB 0. If I use the same command on the console the file z1.txt will be stroaged.

On openhab I get an error

2018-11-29 21:58:41.167 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'zaehler.things'

==> /var/log/openhab2/events.log <==

2018-11-29 21:58:41.239 [me.event.ThingUpdatedEvent] - Thing 'exec:command:zaehler' has been updated.

2018-11-29 21:58:41.261 [vent.ItemStateChangedEvent] - Zaehler_strom changed from We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified to cat: invalid option -- 'l'

Try 'cat --help' for more information.

cat: invalid option -- 'l'

Try 'cat --help' for more information.

I can not understand what’s wrong ?!

Very likely the exec command is executed via sudo and you get the output of that.

Not sure how, but you don’t want sudo in the chain of commands.

check this out:

It’s doesent running well.

I put the command in a zaehler.sh and executed from the terminal. (Its working correct!)

Can I run the zaehler.sh by the exec?

Thx Jens

as which user?
did you read the linked thread?

Hi, i’m reading the thread.
I change the sudoes and disable the password function. I try as user openHabian

then you didn’t read the thread (yet)
it explains that the OH2 process runs as the openhab user (not openHabian)