我有一个名为test_cmd.js的简单的node js程序。我想通过unix shell运行这个程序,并使用该程序的输出来执行unix命令。
test_cmd.js可以简单地为:
console.log('echo "hello, world!"');输出:
>> pi@raspberrypi ~/ $ node test_cmd.js
>> echo "hello, world!" # I want the unix shell I just ran this program in to run this output as a command, but how?发布于 2020-07-06 06:27:42
您通过管道将其作为stdin传递给shell:
$ node test_cmd.js | bash
hello, world!https://stackoverflow.com/questions/62746222
复制相似问题