IAM的嘗試使用的node.js產卵執行一個終端命令
執行終端指令爲正在使用的代碼
console.log(args)
var child = spawn("hark", args, {cwd: workDir});
child.stdout.on('data', function(data) {
console.log(data.toString())
});
child.stderr.on('data', function(data) {
console.log('stdout: ' + data);
});
child.on('close', function(code) {
console.log('closing code: ' + code);
});
But it treated greater than
>as string
「>」和 獲得輸出作爲
tshark: Invalid capture filter "> g.xml"
That string isn't a valid capture filter (syntax error).
See the User's Guide for a description of the capture filter syntax.
如何使用>
沒有串
'> ggggg.xml'是用於將stdout重定向到文件的shell語法。你應該使用spawn http://nodejs.org/api/child_process.html#child_process_options_stdio的正確選項或使用'child_process.exec'來調用shell。 – 2015-02-10 07:51:30