public
Created

Problem reading casperjs output into nodejs

  • Download Gist
cron.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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);
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.