node子进程(Child Process)获取硬盘分区
node child_process文档
child_process.exec(command[, options][, callback])
command
<string> The command to run, with space-separated arguments.options
<Object>cwd
<string> Current working directory of the child process. Default:null
.env
<Object> Environment key-value pairs. Default:null
.encoding
<string> Default:'utf8'
shell
<string> Shell to execute the command with. See Shell Requirements and Default Windows Shell. Default:'/bin/sh'
on UNIX,process.env.ComSpec
on Windows.timeout
<number> Default:0
maxBuffer
<number> Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated. See caveat atmaxBuffer
and Unicode. Default:200 * 1024
.killSignal
<string> | <integer> Default:'SIGTERM'
uid
<number> Sets the user identity of the process (seesetuid(2)
).gid
<number> Sets the group identity of the process (seesetgid(2)
).windowsHide
<boolean> Hide the subprocess console window that would normally be created on Windows systems. Default:false
.
callback
<Function> called with the output when process terminates.
init(list){//得到硬盘分区的数组
let ths = this;
let lists = ths.arrayTrim(list);
return lists;
}
arrayTrim(arr){//数组中各元素的空格去除
arr.shift();
arr.forEach(function(item, index){
arr[index] = item.trim();
});
return arr;
}
logicaldisk(){//获取自盘分区的字符串
var ths = this;
spawn.exec('wmic logicaldisk get caption', {
windowsHide: true
}, function(err, stdout, stderr) {
if(err || stderr) {
console.log("root path open failed" + err + stderr);
return;
}
let disks = stdout.trim().split('\n');
ths.init(disks);
})
}
node子进程(Child Process)获取硬盘分区的更多相关文章
- 如何在Linux 中获取硬盘分区或文件系统的UUID?
作为一个 Linux 系统管理员,你应该知道如何去查看分区的 UUID 或文件系统的 UUID.因为现在大多数的 Linux 系统都使用 UUID 挂载分区.你可以在 /etc/fstab 文件中可以 ...
- [Node.js] Child Process with fork() to handle heavy calculation process
When build server, if we have a API endpoint requires some heavy calculation process, it will block ...
- NSIS:获取硬盘中容量最大的分区盘符
原文 NSIS:获取硬盘中容量最大的分区盘符 我们在安装一些在线视频软件比如迅雷看看时,会发现他们的安装程序会自动判断当前系统中容量最大的分区,以便在其中创建数据缓冲下载的文件夹,这种功能如果实现呢, ...
- node中非常重要的process对象,Child Process模块
node中非常重要的process对象,Child Process模块Child Process模块http://javascript.ruanyifeng.com/nodejs/child-proc ...
- Child Process模块
目录 exec() execSync() execFile() spawn() fork() send() 参考链接 child_process模块用于新建子进程.子进程的运行结果储存在系统缓存之中( ...
- linux系统监控与硬盘分区/格式化/文件系统管理
1.系统监控 1) 系统监视和进程控制的工具----> Top 与 free 类似于windows的资源管理器. 进程运行的三种状态: tips: 进程(Process)是计 ...
- Child Process
Child Process child_process 这个模块可以生成一个子进程.nodejs提供了好几个API,本质上都是调用child_process.spawn(): const spawn ...
- 在nodejs中创建child process
目录 简介 child process 异步创建进程 同步创建进程 在nodejs中创建child process 简介 nodejs的main event loop是单线程的,nodejs本身也维护 ...
- 聊聊 node 如何优雅地获取 mac 系统版本
背景 今天突然碰到了一个兼容性需求,需要根据不同 macOS 版本,进行不同的兼容性处理. 没想到看似简单的需求,中间也经历了一番波折,好在最后解决了问题. 在此记录一下解决问题的过程,也方便其他有类 ...
随机推荐
- 深浅拷贝 set集合
数据类型的补充 编码转换 # s1 = '中国' # b1 = s1.encode('utf-8') # # print(b1)-------------->b'\xe4\xb8\xad\xe5 ...
- 从大厂DevOps工具链部署,看现代产品的生命周期管理
目录 1. 认识DevOps 1.1. DevOps工具链 1.2. CI 持续集成(Continuous Integration) 1.3. CD(持续交付 & 持续部署) 1.4. Agi ...
- (二)MySQL8.0(ZIP)、SQLyog安装
一.mysql8.0(ZIP)的安装 安装时看了很多的文章,开始选择的是客户端安装后一直安装失败,就选择了zip安装. 注意:该方法仅适用于8.0版本安装,其余版本未测试 1.下载zip压缩包(两个都 ...
- OO第四单元——终章
一.架构设计 这一单元的作业主要是围绕UML来对我们的面向对象思维进行训练,刚开始接触的时候或许因为些许陌生而觉得有一定难度,但随着一次一次的代码阅读再加上思考,逐渐地也变得得心应手了起来. 1.第一 ...
- VM virtualBox中文版 v6.0.12.133076官方版(64/-虚拟机
virtualBox中文版 v6.0.12.133076官方版(64/-虚拟机 http://www.onlinedown.net/soft/82464.htm http://8dx.pc6.com/ ...
- C语言实现类
#ifndef __DEFINE__H__ #define __DEFINE__H__ #define vector3(type) \ typedef struct vector3_##type { ...
- 图解leetcode5-10 | 和233酱一起刷leetcode系列(2)
本周我们继续来看5道磨人的小妖精,图解leetcode6-10- 多说一句,leetcode10 杀死了233酱不少脑细胞... 另: 沉迷算法,无法自拔.快来加入我们吧! 别忘了233酱的一条龙服务 ...
- 利用synchronized解析死锁的一种形成方式
代码 import ... public class Test{ private static Object o1=new Object(); private static Object o2=new ...
- spring cloud config 配置文件更新
Spring Cloud Config Server 作为配置中心服务端 拉取配置时更新 git 仓库副本,保证是最新结果 支持数据结构丰富,yml, json, properties 等 配合 eu ...
- springBoot--集成RocketMQ
1.导入依赖 <dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>sprin ...