Calling an external process from renderer using remote


#1

Hi,

I’m calling a function using remote that uses nodes child process. However, I cannot get the value for stdout as a return value top the renderer process. I’ve tried using promises but that didn’t work either.

What am I missing here ?

Here’s my code:
exports.call_python = function () {

    var stdout = ""

     var childProcess = require('child_process'),
         ls;

     ls = childProcess.exec('ls -l', function (error, stdout, stderr) {
         if (error) {
             console.log(error.stack);
             console.log('Error code: '+error.code);
             console.log('Signal received: '+error.signal);
         }
         console.log('Child Process STDOUT: '+stdout);
         console.log('Child Process STDERR: '+stderr);
     });

     ls.on('exit', function (code) {
         console.log('Child process exited with exit code '+code);
         
     });

     return stdout
 };

#2

OK so it seems this is the way to do this:

return ChildProcess.execSync( command ).toString();

Is there anything documented that covers the different approaches that can be taken here ?