Created
March 20, 2012 04:03
-
-
Save jessefulton/2131204 to your computer and use it in GitHub Desktop.
Problem reading casperjs output into nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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