Skip to content

Instantly share code, notes, and snippets.

@jessefulton
Created March 20, 2012 04:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessefulton/2131204 to your computer and use it in GitHub Desktop.
Save jessefulton/2131204 to your computer and use it in GitHub Desktop.
Problem reading casperjs output into nodejs
var spawn = require('child_process').spawn;
var bin = "casperjs"
//googlelinks.js is the example given at http://casperjs.org/#quickstart
var args = ['scripts/googlelinks.js'];
var cspr = spawn(bin, args);
//cspr.stdout.setEncoding('utf8');
cspr.stdout.on('data', function (data) {
var buff = new Buffer(data);
console.log("foo: " + buff.toString('utf8'));
});
cspr.stderr.on('data', function (data) {
data += '';
console.log(data.replace("\n", "\nstderr: "));
});
cspr.on('exit', function (code) {
console.log('child process exited with code ' + code);
process.exit(code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment