执行Linux shell脚本时出错

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

#!/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; 

和错误消息: 控制台错误

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

尝试

 #!/bin/bash nodejs /var/www/nodejs/server.js