我需要在nodejs脚本中执行一些shell命令 之前都是使用 child_process
后来尝试 execa
时,执行一些稍微复杂些的命令 无效 比如 我想执行
echo 'hello world!' > /test/hello.txt
使用 child_process
可以正常执行 没有问题 语法为
process.exec(`echo 'hello world!' > /test/hello.txt`,function(){xxx})
使用 execa
执行不报错 但无法写入这个文件 没有效果 语法为
execa('echo', [`'hello world!'`,'>','/test/hello.txt'])
or
execa('echo', [`'hello world!' > /test/hello.txt`])
两种方式均无效
不知是否是我的调用语法或者传参有错误