【笔记】Nodejs执行Shell命令
前言
Nodejs执行Shell命令
当前进程执行Shell命令
1 | const { exec } = require("child_process"); |
子进程执行Shell命令
{}:第三个参数是其他选项
cwd: "":当前命令执行的工作目录env: {}:临时使用的系统环境变量shell: true:是否通过Shell执行命令detached: true:子进程脱离父进程独立执行timeout: 0:超时时间,单位毫秒
1 | const { spawn } = require("child_process"); |
1 | const { spawn } = require("child_process"); |
执行可执行文件
1 | const { execFile } = require("child_process"); |