简体   繁体   English

从PHP执行bash脚本文件

[英]executing bash script file from php

I am trying to call a bash script from my php file of click of a button that simple creates a directory. 我试图从单击简单创建目录的按钮的php文件中调用bash脚本。 However, when i run from the web it would not do anything when i run from the terminal it works fine. 但是,当我从网络运行时,从终端运行时它什么也不会做。

Not sure what the problem is ? 不确定是什么问题 ?

test.php test.php的

header('Content-Type: application/json');
$result =shell_exec('sh /var/www/shellscriptphp/test.sh ');
exit();

test.sh test.sh

mkdir testfolder

Just to close the question, your code works as long as your uid has permissions on the server's filesystem. 只是为了解决问题,只要您的uid拥有服务器文件系统的权限,您的代码就可以工作。

You can change permissions in the filesystem using chmod (see man chmod for details). 您可以使用chmod更改文件系统中的权限(有关详细信息,请参见man chmod )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM