CNode

child_process 调用shell脚本 好像又打开了一扇窗

分享
RRock-1发布于9 年前最后回复9 年前0 回复5211 浏览0 收藏

demo.js

const callfile = require('child_process');
const newpassword = 'newpwd';
callfile.exec('./a.sh one two three',function (err, stdout, stderr) {
    console.dir(arguments);
});

a.sh

echo "执行的文件名:$0";
echo "第一个参数为:$1";
echo "第二个参数为:$2";
echo "第三个参数为:$3";

输出

{ '0': null,
  '1': '第一个参数为:one\n第二个参数为:two\n第三个参数为:three\n',
  '2': '' }

查看回复

回复 (0)

暂无回复,成为第一个参与讨论的人。
参与回复
登录后即可参与回复。登录