Node-cmd
安裝:
npm install node-cmd
npm install node-cmd –save // 安裝到工程目錄
兩種運行命令行方式:
method | arguments | functionality |
---|---|---|
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'); }
參考:
Node-cmd npm
child_process
參考: