Node(18) child_process
来源:互联网 发布:软件联盟推广平台源码 编辑:程序博客网 时间:2024/06/05 14:07
child_process has stdin and stdout for input and output
child_process.exec(command, [options], callback)
execute a command
default options:
var options = { encoding: 'utf8', timeout: 0, maxBuffer: 200 * 1024, killSignal: 'SIGTERM', setsid: false, cwd: null, env: null };
var cp = require( 'child_process');cp.exec( 'ls -l', function( e, stdout, stderr ){if( !e ){console.log( stdout );}});
spawn is more general purpose, it require you to do stdin stdout callback yourself.
simple example to use stdin and stdout to list files and foulders:
//create child process for terminalvar terminal = require('child_process').spawn('bash');//when terminal receive data, print it to consoleterminal.stdout.on('data', function (data) { console.log('stdout: ' + data);});//when terminal exit, print code to notify userterminal.on('exit', function (code) { console.log('child process exited with code ' + code);});//write data to terminal through stdinsetTimeout(function() { console.log('Sending stdin to terminal'); terminal.stdin.write('ls -lah'); terminal.stdin.end();}, 1000);
- Node(18) child_process
- Node.js子进程child_process
- node child_process模块学习笔记
- Node.js 使用 child_process 实现多进程
- Node.js进程通信模块child_process
- Node.js进程通信模块child_process
- Node.js进程通信模块child_process
- Node.js 使用 child_process 实现多进程
- 【nodejs --学习01】: node之child_process
- Node.js学习笔记(6、child_process模块)
- Node.js child_process模块中的spawn和exec方法
- Node.js使用child_process运行脚本的输入输出错误
- Node child_process的fork,spawn,exec我有话要说
- Node.js 中 child_process模块的spawn和exec 方法之间的区别
- linux 下node.js 使用child_process模块的exec方法所遇问题
- 从Node.js的child_process模块来学习父子进程之间的通信
- nw.js node-webkit系列(25)child_process中spawn和exec方法的使用
- node.js 在使用child_process 模块时候,调试端口占用的问题解决方案(EADDRINUSE)
- SQL基本语句及基础知识
- 2012.7.26
- 2012.7.27
- CHM 格式打不开
- Android布局文件中的各种属性
- Node(18) child_process
- FVWM
- GUI
- 【版本控制工具】svn服务器、客户端安装配置及eclipse的svn检出
- c语言最后一个程序链表
- ELF文件在带加载器的OS中和裸奔的加载及运行
- sicily--1931. 卡片游戏
- 用C++进行函数式编程
- Linux下的lds链接脚本简介