【发布时间】:2015-02-10 07:45:10
【问题描述】:
我正在尝试使用 node.js spawn 执行终端命令
因为我正在使用代码
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' 是将标准输出重定向到文件的 shell 语法。您应该使用正确的 spawn 选项 nodejs.org/api/child_process.html#child_process_options_stdio 或使用
child_process.exec这将调用 shell。
标签: abc