// This node.js example wraps the result of running "ps -a" in HTML // and serves it at localhost:8080. It uses a meta tag // to refresh the display every 5 seconds. var sys = require('sys'), http = require('http'), command = "ps -a"; function buildHtml(str) { var head = '
'; var body = '' + str + ''; return ['', head, body, ''].join('\n'); } http.createServer(function(req, res) { sys.exec(command).addCallback(function (stdout, stderr) { res.sendHeader(200, {'Content-Type': 'text/html'}); res.sendBody(buildHtml(stdout)); res.finish(); }); }).listen(8080); sys.puts('Server running at http://127.0.0.1:8080/');