Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 执行Linux shell脚本时出错_Php_Linux_Node.js_Shell - Fatal编程技术网

Php 执行Linux shell脚本时出错

Php 执行Linux shell脚本时出错,php,linux,node.js,shell,Php,Linux,Node.js,Shell,我试图在dhtmlx实时更新框架中执行一个shell脚本来启动nodejs服务器。根据dhtmlx文档,nodejs服务器将放在web根目录中。我已经在/var/www(nodejs文件夹所在的位置)中编写了一个批处理文件,这样就可以启动服务器,或者根据需要重新启动服务器,而无需打开终端: #!/bin/bash nodejs nodejs/server.js 在脚本中,有一个对php脚本的ajax调用: $("#starter").click(function(response){

我试图在dhtmlx实时更新框架中执行一个shell脚本来启动nodejs服务器。根据dhtmlx文档,nodejs服务器将放在web根目录中。我已经在/var/www(nodejs文件夹所在的位置)中编写了一个批处理文件,这样就可以启动服务器,或者根据需要重新启动服务器,而无需打开终端:

#!/bin/bash
nodejs nodejs/server.js
在脚本中,有一个对php脚本的ajax调用:

$("#starter").click(function(response){
    var jqxhr = $.ajax( "./phpFunctions/nodeStarter.php" )
    .done(function(response) {
        alert(response);
    })
    .fail(function() {
        alert(response);
    })
});
在nodeStarter.php中,执行以下操作:

error_reporting(E_ERROR | E_WARNING | E_PARSE);
$output = shell_exec("/var/www/nodeStart 2>&1; echo $?");
echo "<pre>$output</pre>";
unset $output;
错误报告(E|u错误| E|u警告| E|u解析);
$output=shell_exec(“/var/www/nodeStart 2>&1;echo$?”;
回显“$output”;
未结算美元产出;
以及错误消息:

嗯?似乎是在web文件夹中查找server.js,而不是在我告诉它的web根目录中。我很困惑。

试试看


谢谢,成功了。在启动时发现一个php错误,unset($output);不喜欢看到任何括号。
#!/bin/bash
nodejs /var/www/nodejs/server.js