ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
脚本可以通过 child_process 模块新建子进程,从而执行 Unix 系统命令。 ~~~ #!/usr/bin/env node var name = process.argv[2]; var exec = require('child_process').exec; var child = exec('echo hello ' + name, function(err, stdout, stderr) { if (err) throw err; console.log(stdout); }); ~~~ 用法如下。 ~~~ $ ./hello tom hello tom ~~~