jazcam
jazcam

Reputation: 135

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: console error

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.

Upvotes: 1

Views: 69

Answers (1)

cmorrissey
cmorrissey

Reputation: 8583

Try

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

Upvotes: 2

Related Questions