我想快速设置网站,所以我现在尝试表达。但我很陌生。 ;-( 我需要在服务器部分调用一些可执行文件,并将结果发送回浏览器。在node.js shell command execution之后,现在完成第一步,但在第二步中发生错误。
这是我的代码:
/* GET home page. */
router.post('/', function (req, res) {
// Run C:\Windows\System32\netstat.exe -an
var foo = new run_cmd(
'netstat.exe', ['-an'],
function (me, buffer) {
me.stdout += buffer.toString()
},
function () {
res.send('netstat done~');
console.log(foo.stdout)
}
);
//console.log(req);
res.render('index', {
title: 'Express'
});
});
function run_cmd(cmd, args, cb, end) {
var spawn = require('child_process').spawn,
child = spawn(cmd, args),
me = this;
child.stdout.on('data', function (buffer) {
cb(me, buffer)
});
child.stdout.on('end', end);
}
有人可以帮助我吗?非常感谢。