码迷,mamicode.com
首页 > Web开发 > 详细

nodejs 运行CMD命令

时间:2017-10-07 22:06:12      阅读:967      评论:0      收藏:0      [点我收藏+]

标签:htm   git   UI   str   head   ejs   shel   javascrip   log   

Node-cmd

安装:

npm install node-cmd

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

两种运行命令行方式:

 

methodargumentsfunctionality
run command runs a command asynchronously
get command,callback runs 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 命令

nodejs 运行CMD命令

标签:htm   git   UI   str   head   ejs   shel   javascrip   log   

原文地址:http://www.cnblogs.com/zhen-android/p/7635893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!