Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

running shell commands nodejs

const exec = require('child_process').exec;
const child = exec('cat *.js bad_file | wc -l',
    (error, stdout, stderr) => {
        console.log(`stdout: ${stdout}`);
        console.log(`stderr: ${stderr}`);
        if (error !== null) {
            console.log(`exec error: ${error}`);
        }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #running #shell #commands #nodejs
ADD COMMENT
Topic
Name
9+3 =