Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created April 13, 2012 02:32
Show Gist options
  • Save dongyuwei/2373102 to your computer and use it in GitHub Desktop.
Save dongyuwei/2373102 to your computer and use it in GitHub Desktop.
nodejs system cmd
var express = require('express'), exec = require('child_process').exec;
var app = express.createServer();
app.use(app.router);
app.get('/ls', function(req, res) {
exec('ls . ', function(error, stdout, stderr) {
console.log(stdout);
res.write(stdout, 'utf-8');
res.write(stderr, 'utf-8');
if(error) {
throw error;
}
res.end('');
});
});
app.listen(8080);
console.log('server ' + process.pid + ' running on 8080 port...');
@dongyuwei
Copy link
Author

tail -f xxx.log 最能体现nodejs chunk输出

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment