nodejs 运行CMD命令

来源:互联网 发布:linux ping带源地址 编辑:程序博客网 时间:2024/05/21 10:41

Node-cmd

安装:

npminstall node-cmd

npminstall node-cmd –save // 安装到工程目录

两种运行命令行方式:

methodargumentsfunctionalityruncommandruns a command asynchronouslygetcommand,callbackruns a command asynchronously, when the command is complete all of the stdout will be passed to the callback

API使用:

var nodeCmd = require('node-cmd');function runCmdTest() {    nodeCmd.get(        'ipconfig',        function(err, data, stderr){            console.log(data);        }    );     nodeCmd.run('ipconfig');}


 参考:

     RIAEvangelist/node-cmd  

         Node-cmd npm

     使用Nodejs在Windows上调用CMD命令

 

child_process

 

参考:

     nodejs调用脚本(python/shell)和系统命令

     Nodejs之如何调用 cmd 命令