gpt4 book ai didi

python - Errno 13 权限被拒绝的 bash 脚本和 apache2

转载 作者:太空宇宙 更新时间:2023-11-04 12:54:06 25 4
gpt4 key购买 nike

我正在尝试运行 bash 脚本以从 BMP280 传感器获取值。

#!/bin/bash
echo "Content-type: text/html"
echo ""
read_bme280 --i2c-address 0x76

网页是空白的,在 error.log 中我得到:

[Tue Mar 29 07:20:40.579423 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: Traceback (most recent call last):
[Tue Mar 29 07:20:40.580102 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: File "/usr/local/bin/read_bme280", line 9, in <module>
[Tue Mar 29 07:20:40.580589 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215:
[Tue Mar 29 07:20:40.581016 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: load_entry_point('bme280==0.2', 'console_scripts', 'read_bme280')()
[Tue Mar 29 07:20:40.581669 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: File "/usr/local/lib/python2.7/dist-packages/bme280/bme280.py", line 210, in main
[Tue Mar 29 07:20:40.582426 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215:
[Tue Mar 29 07:20:40.582811 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: bme280_i2c.set_default_bus(int(args.i2c_bus))
[Tue Mar 29 07:20:40.583487 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: File "/usr/local/lib/python2.7/dist-packages/bme280/bme280_i2c.py", line 22, in set_default_bus
[Tue Mar 29 07:20:40.583991 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215:
[Tue Mar 29 07:20:40.584345 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: default_bus = smbus.SMBus(bus_number)
[Tue Mar 29 07:20:40.584836 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: IOError
[Tue Mar 29 07:20:40.587657 2016] [cgi:error] [pid 1280] [client 10.20.30.127:34334] AH01215: : [Errno 13] Permission denied

从 cli 中,脚本运行得很好。无法弄清楚“权限被拒绝”问题出在哪里。

最佳答案

如果 tte 文件由 root 拥有,则尝试 chmod +s/usr/local/bin/read_bme280。它应该允许脚本以 root 权限运行,从而可以访问所有内容。

作为安全预防措施,您可以确保其他用户无法编辑此文件。

关于python - Errno 13 权限被拒绝的 bash 脚本和 apache2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36278041/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com