# Permission error when executing python or shell script reading the I2C/smbus via EXEC (OH2.5.4 on Pi4 Buster)

**URL:** <https://community.openhab.org/t/permission-error-when-executing-python-or-shell-script-reading-the-i2c-smbus-via-exec-oh2-5-4-on-pi4-buster/98930>\
**Category:** Beginners\
**Tags:** exec, python, permissions\
**Created:** [May 16, 2020, 3:14pm UTC](https://community.openhab.org/t/permission-error-when-executing-python-or-shell-script-reading-the-i2c-smbus-via-exec-oh2-5-4-on-pi4-buster/98930 "2020-05-16T15:14:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tost](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@tost](https://community.openhab.org/u/tost)\
**Post date:** [May 16, 2020, 3:14pm UTC](https://community.openhab.org/t/permission-error-when-executing-python-or-shell-script-reading-the-i2c-smbus-via-exec-oh2-5-4-on-pi4-buster/98930/1 "2020-05-16T15:14:26Z")

</div>

Hi all,

I’m totally new with openHab and surely not a Linux guru… so I run into some trouble getting sensor data from a BME280, where I hope you can help me with.

Please excuse my English, it’s not my native tongue.

Info’s on my problem:

- Pi4 with Buster

- self installed openHab 2.5.4. with Zulu8

- i would like to read out a BME 280 via a script (because i can then implement other things similar)

- i tried to read the sensor via python script or this python script run via a shell script

- both the \*.sh or the \*.py scripts are running and reading data if I (user pi) execute them

- I found i need to whitelist EXEC commands → done, i think it is working in principle

- the script is owned by openhub and has -u rwx -g rx -o rx permissions

- the user openhab is in the groups i2c, gpio, spi, input, tty

- the script is executed every 60s

My problem is:

Instead of the string (i later want to read data out of it, but this is a task to be done in the future) i expect with the python script output (which is exactly the same as the output the shell script generates by executing the phython script), i get the following:

“Traceback (most recent call last): File “/var/lib/openhab2/bme280.py”, line 30, in bus = smbus.SMBus(1) # Rev 2 Pi, Pi 2 & Pi 3 uses bus 1 IOError: [Errno 13] Permission denied Traceback (most recent call last): File “/var/lib/openhab2/bme280.py”, line 30, in bus = smbus.SMBus(1) # Rev 2 Pi, Pi 2 & Pi 3 uses bus 1 IOError: [Errno 13] Permission denied”

So there seems to be a problem with the permissions… do you have an idea how i can resolve this? I tried to google it but fail to search for the fitting keywords.

Best wishes

Tobias

---

<div class="post-metadata">

**Author:** ![JustinG](https://community.openhab.org/user_avatar/community.openhab.org/justing/32/55948_2.png) [@JustinG](https://community.openhab.org/u/JustinG)\
**Post date:** [May 16, 2020, 4:11pm UTC](https://community.openhab.org/t/permission-error-when-executing-python-or-shell-script-reading-the-i2c-smbus-via-exec-oh2-5-4-on-pi4-buster/98930/2 "2020-05-16T16:11:29Z")

</div>

If you have a working python script it will probably be easier just to use the [rest api](https://www.openhab.org/docs/configuration/restdocs.html) to send data openHab items directly from python

```auto
import requests

requests.post('http://[openHab address]/rest/items/[itemname]', data = '[new value for openHab item]')

```

---

<div class="post-metadata">

**Author:** ![tost](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@tost](https://community.openhab.org/u/tost)\
**Post date:** [May 26, 2020, 9:40pm UTC](https://community.openhab.org/t/permission-error-when-executing-python-or-shell-script-reading-the-i2c-smbus-via-exec-oh2-5-4-on-pi4-buster/98930/3 "2020-05-26T21:40:34Z")

</div>

Hello Justin,  
your tip is much appreciated, and it is a nice workaround even if it did not solve my problem directly. Nevertheless, after tinkering a lot which should not have changed any execution or owner rights it now works… So currently I have two working options ;).

Best wishes  
Tobias
