Created
April 13, 2012 02:32
-
-
Save dongyuwei/2373102 to your computer and use it in GitHub Desktop.
nodejs system cmd
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 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...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tail -f xxx.log 最能体现nodejs chunk输出