[SOLVED] Which user excutes a script as a result of an active Rule executeCommandLine?

  • Platform information:

    • Hardware: Raspberry Pi 3
    • OS: Linux openHABianPi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l
    • Java Runtime Environment: openjdk version “1.8.0_152”
    • openHAB version:2.4.0-1 (Release Build)
  • Issue of the topic:

As a complete newcomer, I tried to write my first rule. Under /etc/openhab2/rules/default.rules I have

rule "Algu ha entrat"
when
    Item Porta_terrassa changed from CLOSED to OPEN
then
    executeCommandLine("/home/openhabian/scripts/portaoberta.sh")
end

The script does nothing else but to add a timestamp in a log file:

#!/bin/bash
echo "Door opened at $(date)" >> /home/openhabian/scripts/log

If I run the script on the command line it does what it should.

Looking at the logs I see:

2019-02-24 18:51:42.567 [vent.ItemStateChangedEvent] - Porta_terrassa changed from CLOSED to OPEN
2019-02-24 18:51:42.620 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/home/openhabian/scripts/portaoberta.sh'

But I do not see any update in the log file… unless I do

chmod a+rw log

My question is: under which user/group is the command line issued? I would prefer the log file to just have the necessary permissions and nothing more.

Thanks in advance!

Since openHAB is run as user “openhab” the rules are run also by user “openhab”.

I see now that the default login name in OpenHabian is “openhabian”, which is of course different from “openhab”. facepalm

Will try to adjust file permissions accordingly.

Thanks!

1 Like