简体   繁体   中英

Error executing Linux shell script

I am trying to execute a shell script to start a nodejs server in the framework of a dhtmlx live update. According to dhtmlx documentation, the nodejs server is to be put in the web root. I've written a batch file located in /var/www (where the nodejs folder is located) so the server can be started, or restarted as needed without having to open a terminal:

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

From a script there is an ajax call to a php script:

$("#starter").click(function(response){
    var jqxhr = $.ajax( "./phpFunctions/nodeStarter.php" )
    .done(function(response) {
        alert(response);
    })
    .fail(function() {
        alert(response);
    })
});

In nodeStarter.php the following:

error_reporting(E_ERROR | E_WARNING | E_PARSE);
$output = shell_exec("/var/www/nodeStart 2>&1; echo $?");
echo "<pre>$output</pre>";
unset $output;

And the error message: 控制台错误

Huh? Seems to be looking for server.js in the web folder, rather than on the web root where I told it. I'm baffled.

Try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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