const { exec } = require('child_process');
exec('ls | grep js', (err, stdout, stderr) => {
if (err) {
//some err occurred
console.error(err)
} else {
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
}
});
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}`);
}
});
const system = require('system-commands')
system('ls').then(output => {
console.log(output)
}).catch(error => {
console.error(error)
})
const exec = require("child_process").exec;
exec("ls -la", function (error, stdout, stderr) {
if (error) {
console.log("Error: " + error);
return;
}
if (stderr) {
console.log("stderr: " + stderr);
return;
}
console.log("stdout: " + stdout);
});