Created
September 14, 2011 02:12
-
-
Save s4y/1215700 to your computer and use it in GitHub Desktop.
child_process.execFile example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var child_process = require('child_process'); | |
// exec: spawns a shell. | |
child_process.exec('ls -lah /tmp', function(error, stdout, stderr){ | |
console.log(stdout); | |
}); | |
// execFile: executes a file with the specified arguments | |
child_process.execFile('ls', ['-lah', '/tmp'], function(error, stdout, stderr){ | |
console.log(stdout); | |
}); |
Does it differenciate this 2 kind of errors:
- child_process didn't find your binary or the process broke;
- a "normal" error code was returned by your binary after execution
How can I execute a js file which is written in es6? I am trying to do something like below:
child_process.execFile('node', ['./script.js'], function(error, stdout, stderr){ console.log(stdout); });
But getting syntax error
how can i open explorer with specific dir with execFile method?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I call the execFile method to run a bash script that returns a list of values?
My bash file (test.sh) returns a list of 8 values but the below script is printing only the last row of the output.