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

    <legend id='LG1RI'><style id='LG1RI'><dir id='LG1RI'><q id='LG1RI'></q></dir></style></legend>

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

      1. <small id='LG1RI'></small><noframes id='LG1RI'>

        与手动执行相比,通过 PhP 执行 bash 脚本给出了不同的结果

        Executing bash script via PhP gives a different result compared to executing manually(与手动执行相比,通过 PhP 执行 bash 脚本给出了不同的结果)
          <bdo id='4HWzk'></bdo><ul id='4HWzk'></ul>

            <legend id='4HWzk'><style id='4HWzk'><dir id='4HWzk'><q id='4HWzk'></q></dir></style></legend>

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

                <tfoot id='4HWzk'></tfoot>
                • <small id='4HWzk'></small><noframes id='4HWzk'>

                    <tbody id='4HWzk'></tbody>
                  本文介绍了与手动执行相比,通过 PhP 执行 bash 脚本给出了不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  正如标题所说,当我尝试通过双击并通过终端按执行手动执行脚本时.它工作正常

                  但是当我运行我的 php 脚本或在终端窗口中输入 php 时

                  /usr/bin/php start_cam.php

                  它锁定(命令没有以$"结束,$"没有显示在终端窗口中以表明它已经结束了任务并且它不能正常工作

                  下面是我的php脚本

                  下面是我的 bash 脚本(cmd_start_cam.sh)

                  !/bin/bashecho '运行启动相机脚本'光盘须藤 chmod 755/etc/rc.local光盘cd RPi_Cam_Web_Interface须藤 chmod u+x RPi_Cam_Web_Interface_Installer.sh须藤 ./RPi_Cam_Web_Interface_Installer.sh 停止须藤 ./RPi_Cam_Web_Interface_Installer.sh 启动echo '完成启动相机脚本'

                  注意:我使用 cd 来确保 im 在我的根目录中,就像文件所在的位置.由于它通过手动执行工作,不认为存在路径问题吗?任何帮助是极大的赞赏.谢谢

                  更新:这是我遇到终端命令窗口输出的错误:

                  我想在我的 bash 脚本命令 echo 'complete start camera script'

                  之后,我遇到了管道损坏

                  终端窗口输出 cmd_start_cam.sh: line 12: echo: write error: Broken Pipe 并没有像正常执行时那样以 $ 结尾>

                  顺便说一下,这是在 raspberry pi 2 上运行的

                  <块引用>

                  更新解决/解决方案:

                  感谢@ikra对检查apache日志文件的洞察力,这让我发现根本原因是权限访问.需要将 www-data 添加到 sudoers 文件中.

                  1. 关于备份和编辑 sudoers 文件的说明:http://raspbypi.com/enabling-the-sudo-command-for-a-new-user/
                  2. sudo visudo
                  3. 在文件末尾添加这个 www-data ALL=(ALL) NOPASSWD: ALL
                  4. 按 CTRL+X 并按是
                  5. 登录和注销以确保现在设置权限.
                  6. 如果您的 sudoer 文件损坏:在终端窗口中输入此内容以修复您输入错误的任何文本 pkexec visudo.(来源:https://askubuntu.com/questions/73864/how-to-modify-a-invalid-etc-sudoers-file-it-throws-out-an-error-and-not-allowi)

                  解决方案

                  感谢 @ikra 对 apache 日志文件的洞察,这让我发现根本原因是权限访问.需要将 www-data 添加到 sudoers 文件中.

                  1. 关于备份和编辑 sudoers 文件的说明:http://raspbypi.com/enabling-the-sudo-command-for-a-new-user/
                  2. sudo visudo
                  3. 在文件末尾添加这个 www-data ALL=(ALL) NOPASSWD: ALL
                  4. 按 CTRL+X 并按是
                  5. 登录和注销以确保现在设置权限.
                  6. 如果您的 sudoer 文件损坏:在终端窗口中输入此内容以修复您输入错误的任何文本 pkexec visudo.(来源:https://askubuntu.com/questions/73864/how-to-modify-a-invalid-etc-sudoers-file-it-throws-out-an-error-and-not-allowi)

                  As the title says, when i try manually executing the script by double clicking and pressing execute through terminal. It works correctly

                  However when i run my php script or typing the php into the terminal window

                  /usr/bin/php start_cam.php
                  

                  It locks up (the command doesn't finish with the "$", "$" does not show in terminal window to show it has ended the task and it doesn't work correctly

                  Below is my php script

                  <?php
                          $command =escapeshellcmd("/bin/bash cmd_start_cam.sh");
                          $output = shell_exec($command);
                          echo $output;
                          echo  "php_startcam2";
                  
                  ?>
                  

                  Below is my bash script(cmd_start_cam.sh)

                  !/bin/bash
                  
                  echo 'running start camera script' 
                  cd
                  sudo chmod 755 /etc/rc.local
                  cd 
                  cd RPi_Cam_Web_Interface 
                  sudo chmod u+x RPi_Cam_Web_Interface_Installer.sh
                  
                  sudo ./RPi_Cam_Web_Interface_Installer.sh stop 
                  sudo ./RPi_Cam_Web_Interface_Installer.sh start
                  echo 'complete start camera script' 
                  

                  Note: I use cd to ensure that im at my root directory as there where the files are. As its working via manual execution, do not think there a path issue? Any help is greatly appreciated. thank you

                  Update: this is the error im experiencing output by the terminal command window:

                  i think i am experiencing a broken pipe as after my bash script command echo 'complete start camera script'

                  terminal window output cmd_start_cam.sh: line 12: echo: write error: Broken Pipe and doesn't end with a $ like it should on normal execution

                  By the way this is running on raspberry pi 2

                  Update Solved/Solution:

                  Thanks to @ikra insight on checking the apache log file, which lead me to discover that the root cause was permission access. www-data needs to be added to the sudoers file.

                  1. Instructions on backing up and editing sudoers file :http://raspbypi.com/enabling-the-sudo-command-for-a-new-user/
                  2. sudo visudo
                  3. add this at the end of the file www-data ALL=(ALL) NOPASSWD: ALL
                  4. Press CTRL+X and press yes
                  5. login and logout to ensure permission is now set.
                  6. If your sudoer file gets corrupted: type this in terminal window to fix whatever text you have typed wrongly pkexec visudo .(Source: https://askubuntu.com/questions/73864/how-to-modify-a-invalid-etc-sudoers-file-it-throws-out-an-error-and-not-allowi)

                  解决方案

                  Thanks to @ikra insight on checking the apache log file, which lead me to discover that the root cause was permission access. www-data needs to be added to the sudoers file.

                  1. Instructions on backing up and editing sudoers file :http://raspbypi.com/enabling-the-sudo-command-for-a-new-user/
                  2. sudo visudo
                  3. add this at the end of the file www-data ALL=(ALL) NOPASSWD: ALL
                  4. Press CTRL+X and press yes
                  5. login and logout to ensure permission is now set.
                  6. If your sudoer file gets corrupted: type this in terminal window to fix whatever text you have typed wrongly pkexec visudo .(Source: https://askubuntu.com/questions/73864/how-to-modify-a-invalid-etc-sudoers-file-it-throws-out-an-error-and-not-allowi)

                  这篇关于与手动执行相比,通过 PhP 执行 bash 脚本给出了不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                    <tbody id='r0f9o'></tbody>

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

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

                          • <legend id='r0f9o'><style id='r0f9o'><dir id='r0f9o'><q id='r0f9o'></q></dir></style></legend>