【发布时间】:2015-12-17 23:11:27
【问题描述】:
我想在节点 js child_process.exec() 中运行带有参数的 bash 脚本
在文档中是String The command to run, with space-separated arguments,但是
child.exec("cat path_to_file1 path_to_file2")
不起作用。内部改为
/bin/sh -c cat path_to_file1 path_to_file2
失败了。我怎样才能正确运行它?在 shell 中我会这样修复它
/bin/sh -c 'cat path_to_file1 path_to_file2'
(我没有写回调,因为我只问命令参数)
【问题讨论】:
-
不确定我是否理解您的问题。
exec("cat file1 file2")工作正常。
标签: node.js child-process electron