spawn
var process = require('child_process');
var file = process.spawn('curl', ['http://jalon.wang/project/photo/app.js']);
var fdata = '';
file.stdout.on('data', function (data) {
fdata = fdata + data;
});
file.stdout.on('end', function (data) {
console.log(fdata);
});
exec
var fs = require('fs');
var process = require('child_process');
process.exec('curl http://jalon.wang/project/photo/app.js', function (err, stdout, stderr) {
fs.writeFile('./app.js', stdout, function (err) {
if (err) console.log(err);
console.log('ok');
});
});