Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Problem reading casperjs output into nodejs
var spawn = require('child_process').spawn;
var bin = "casperjs"
//googlelinks.js is the example given at
var args = ['scripts/googlelinks.js'];
var cspr = spawn(bin, args);
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment