javascript - Stream a command's response up to node -
i'm trying make node package executes permanent script keeps printing data , passes package caller.
i use exec object, in order call command:
var exec = require('child_process').exec; // ... exec("script always", function(error, stdout, stderr) { if (error instanceof error) { throw error; } // here's gets messy if(callback) callback(stream) });
this command keeps printing data until stop it. now, how stream console output node event wants implement? i've been reading readable stream, don't know how tie (actually, heh, have function getreadablestreamsomehow()
sake of examples).
you should use spawn
, not exec
, described here. return object have direct access program's streams, can pipe
them, e.g., or subscribe data
events.
see this example sample on how capture output of curl
command.
hope helps :-)
Comments
Post a Comment