du4629 2016-02-18 19:52
浏览 36
已采纳

如何在服务器中从php执行源命令

I am unable to execute a source command in linux using php.All other commands are working except this one. I need to execute the following command.

 source /root/Envs/ate/bin/activate

This activates the ate-Automatic Test Equipment.Once I activate it then I need to run a python script as the script accesses the remote server. I am able to manually run it but I am creating a tool which will automatically do it.

  <?php
  exec("source /root/Envs/ate/bin/activate", $output, $return);
  echo "Command returned $return, and output:
";
  echo exec("python box_upgrade-pradeepa.py");
  ?>

The above commands returns 1 which means there is an error.But I am not sure how to run the 'source command'. The python script will run only if the source command is successful.(the python command is correct as I replaced hello.py and it ran fine.) Could you pls help me as I am really stuck for a week? Thanks a lot..

  • 写回答

1条回答 默认 最新

  • doubo1871 2016-02-22 23:51
    关注

    I found out the error. Since I am doing it using php (for a web tool) the user is Apache. 'Apache' user is unable to access the script in root folder. Moving it to another directory, I am able to run the script fine.

    Thanks all..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?