child_process.spawn() piping
var child_process = require('child_process');
var cmd = 'ls';
var value = ['-z', '/usr'];
var opt = { };
var child = child_process.spawn(cmd, value, opt);
child.stdout.on('data', function (data) {
console.log("IM HERE");
console.log('data' + data);
});
child.stderr.on('data', function (data) {
console.log("IM HERE - Error");
console.log('test: ' + data);
});
child.on('close', function (code) {
console.log("IM HERE");
console.log("close");
});
var child_process = require('child_process');
var cmd = 'ls';
var value = ['-z', '/usr'];
var opt = { };
var child = child_process.spawn(cmd, value, opt);
child.stdout.on('data', function (data) {
console.log("IM HERE");
console.log('data' + data);
});
child.stderr.on('data', function (data) {
console.log("IM HERE - Error");
console.log('test: ' + data);
process.exit(1);
});
child.on('close', function (code) {
console.log("IM HERE");
console.log("close");
});
no comments