I\'m trying to launch a shell command from Node.js, without redirecting that command\'s input and output -- just like shelling out to a command using a shell script, or
I haven't used it, but I've seen this library: https://github.com/polotek/procstreams
It you'd do this. The .out()
automatically pipes to the process's stdin/out.
var $p = require('procstreams');
$p('cat lines.txt').pipe('wc -l').out();
If doesn't support shell syntax, but that's pretty trivial I think.
var command_str = "cat lines.txt | wc -l";
var cmds = command_str.split(/\s?\|\s?/);
var cmd = $p(cmds.shift());
while(cmds.length) cmd = cmd.pipe(cmds.shift());
cmd
.out()
.on('exit', function() {
// Do whatever
});