<bdo id='o3J1z'></bdo><ul id='o3J1z'></ul>

  • <legend id='o3J1z'><style id='o3J1z'><dir id='o3J1z'><q id='o3J1z'></q></dir></style></legend>
    1. <small id='o3J1z'></small><noframes id='o3J1z'>

      <i id='o3J1z'><tr id='o3J1z'><dt id='o3J1z'><q id='o3J1z'><span id='o3J1z'><b id='o3J1z'><form id='o3J1z'><ins id='o3J1z'></ins><ul id='o3J1z'></ul><sub id='o3J1z'></sub></form><legend id='o3J1z'></legend><bdo id='o3J1z'><pre id='o3J1z'><center id='o3J1z'></center></pre></bdo></b><th id='o3J1z'></th></span></q></dt></tr></i><div id='o3J1z'><tfoot id='o3J1z'></tfoot><dl id='o3J1z'><fieldset id='o3J1z'></fieldset></dl></div>
      <tfoot id='o3J1z'></tfoot>

      1. Raspberry PI:PHP 使用 sudo 调用 python 脚本

        Raspberry PI: PHP call python script with sudo(Raspberry PI:PHP 使用 sudo 调用 python 脚本)
          <bdo id='0AZsV'></bdo><ul id='0AZsV'></ul>

              <small id='0AZsV'></small><noframes id='0AZsV'>

                <tbody id='0AZsV'></tbody>
              <i id='0AZsV'><tr id='0AZsV'><dt id='0AZsV'><q id='0AZsV'><span id='0AZsV'><b id='0AZsV'><form id='0AZsV'><ins id='0AZsV'></ins><ul id='0AZsV'></ul><sub id='0AZsV'></sub></form><legend id='0AZsV'></legend><bdo id='0AZsV'><pre id='0AZsV'><center id='0AZsV'></center></pre></bdo></b><th id='0AZsV'></th></span></q></dt></tr></i><div id='0AZsV'><tfoot id='0AZsV'></tfoot><dl id='0AZsV'><fieldset id='0AZsV'></fieldset></dl></div>
            1. <legend id='0AZsV'><style id='0AZsV'><dir id='0AZsV'><q id='0AZsV'></q></dir></style></legend>
                • <tfoot id='0AZsV'></tfoot>
                  本文介绍了Raspberry PI:PHP 使用 sudo 调用 python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在使用 PHP 5.4.14 (fpm-fcgi) 的 Raspberry PI 上运行 Nginx.这一切都很好.但是在一个脚本中,我使用 shell_exec 进行了 shell 调用.

                  i'm running Nginx on my Raspberry PI with PHP 5.4.14 (fpm-fcgi). It all works well. But in one script i make a shell call using shell_exec.

                  echo shell_exec("sudo python " . $file);
                  

                  如果我将控制台与

                  php test.php
                  

                  但是如果我使用浏览器调用这个文件,php 文件将被执行,但我没有得到 shell_exec 的任何输出(甚至没有错误消息).

                  but if i use the browser to call this file the php-file will be executed but i don't get any output by the shell_exec (not even an error message).

                  所以我希望你能帮我解决这个问题.

                  So i hope you could help me fix this problem.

                  被调用的python文件使用了GPIO,所以需要sudo,对吗?

                  The called python file makes use of the GPIO so sudo is required, right?

                  这是我的python代码:

                  Here is my python code:

                  #!/usr/bin/env python
                  try:
                      import RPi.GPIO as GPIO
                  except RuntimeError:
                      print "Error Importing GPIO. Did your forgot the superuser privilieges?"
                  
                  GPIO.setmode(GPIO.BOARD)
                  GPIO.setwarnings(False)
                  
                  GPIO.setup(3, GPIO.OUT)
                  
                  GPIO.output(3, not GPIO.input(3))
                  
                  print "New LED state is: ", GPIO.input(3)
                  
                  #GPIO.cleanup()
                  

                  推荐答案

                  供以后参考:

                  我发现了一个 - 我的眼睛 - 不是很好的解决方案:

                  I found a - i my eyes - not really nice solution:

                  sudo echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
                  

                  在此处找到.

                  这篇关于Raspberry PI:PHP 使用 sudo 调用 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP setlocale doesn#39;t work(PHP setlocale 不起作用)
                  mqtt on Laravel with PHP(使用 PHP 在 Laravel 上的 mqtt)
                  PhpSerial: No stty available -- cant seem to get it working(PhpSerial:没有可用的 stty——似乎无法让它工作)
                  Nginx with phpmyadmin wrong redirect after login(登录后带有phpmyadmin的Nginx错误重定向)
                  Docker Swarm get real IP (client host) in Nginx(Docker Swarm 在 Nginx 中获取真实 IP(客户端主机))

                      <small id='gH1kA'></small><noframes id='gH1kA'>

                    1. <i id='gH1kA'><tr id='gH1kA'><dt id='gH1kA'><q id='gH1kA'><span id='gH1kA'><b id='gH1kA'><form id='gH1kA'><ins id='gH1kA'></ins><ul id='gH1kA'></ul><sub id='gH1kA'></sub></form><legend id='gH1kA'></legend><bdo id='gH1kA'><pre id='gH1kA'><center id='gH1kA'></center></pre></bdo></b><th id='gH1kA'></th></span></q></dt></tr></i><div id='gH1kA'><tfoot id='gH1kA'></tfoot><dl id='gH1kA'><fieldset id='gH1kA'></fieldset></dl></div>
                          <tbody id='gH1kA'></tbody>
                          • <bdo id='gH1kA'></bdo><ul id='gH1kA'></ul>
                            <legend id='gH1kA'><style id='gH1kA'><dir id='gH1kA'><q id='gH1kA'></q></dir></style></legend>
                            <tfoot id='gH1kA'></tfoot>