1

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.

1 Answer 1

2

Try

#!/bin/bash
nodejs /var/www/nodejs/server.js
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that did it. And found a php error once it got to cranking, unset($output); Didn't like not seeing any parentheses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.