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)
暂无回复,成为第一个参与讨论的人。
参与回复
登录后即可参与回复。登录