[英]Why does function not get executed when called through web server?
There is a python script: 有一个python脚本:
#!/usr/bin/env python
import sys
import subprocess
subprocess.call("sudo /var/www/scripts/setPwm "+ sys.argv[1],shell=True)
print ("Content-type: text/plain;charset=utf-8\n\n")
print("sudo /var/www/scripts/setPwm "+ sys.argv[1])
print("ok\n")
When run locally it lights up a LED with specified intensity. 在本地运行时,它会以指定的强度点亮一个LED。 When called through a website it prints all correctly, but the LED does not light up.
通过网站调用时,它可以正确打印所有内容,但是LED不会点亮。
When I call 当我打电话
http://sauna/scripts/setLED.py?1000
this is printed: 这是打印:
sudo /var/www/scripts/setPwm 1000
ok
so the argument is apparently passed correctly, there are also no errors in apache log. 因此参数显然已正确传递,apache日志中也没有错误。 Still there is no light :(
仍然没有光:(
问题是,apache服务器与我的用户( www-data
)是不同的用户。将用户( www-data
)添加到/etc/sudoers
以获取需要以root用户身份运行的特定可执行文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.