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.ComSpecon Windows.timeout<number> Default:0maxBuffer<number> Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated. See caveat atmaxBufferand 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 版本,进行不同的兼容性处理. 没想到看似简单的需求,中间也经历了一番波折,好在最后解决了问题. 在此记录一下解决问题的过程,也方便其他有类 ...
随机推荐
- 循序渐进VUE+Element 前端应用开发(10)--- 基于vue-echarts处理各种图表展示
在我们做应用系统的时候,往往都会涉及图表的展示,综合的图表展示能够给客户带来视觉的享受和数据直观体验,同时也是增强客户认同感的举措之一.基于图表的处理,我们一般往往都是利用对应第三方的图表组件,然后在 ...
- 从零开始的Spring Boot(5、Spring Boot整合Thymeleaf)
Spring Boot整合Thymeleaf 写在前面 从零开始的Spring Boot(4.Spring Boot整合JSP和Freemarker) https://www.cnblogs.com/ ...
- 百度文本编辑器的toolbars属性值描述
toolbars: [ [ 'anchor', //锚点 'undo', //撤销 'redo', //重做 'bold', //加粗 ...
- rust 支持的CPU架构
Available CPUs for this target: native - Select the CPU of the current host (currently haswell). amd ...
- Redis删除策略和逐出策略
本文知识点 过期数据概念 数据删除策略 逐出算法 过期数据 先来看三个key值,分别为sex.name.age. 这三个值设置的指令为 set name kaka setex age 100 24 s ...
- MongoDB设计方法及技巧
MongoDB是一种流行的数据库,可以在不受任何表格schema模式的约束下工作.数据以类似JSON的格式存储,并且可以包含不同类型的数据结构.例如,在同一集合collection 中,我们可以拥有以 ...
- Hystrix Stream的监控页面不显示内容
打开Hystrix Stream页面,进入后,发现只有一行Unable to connect to Command Metric Stream. 因为springboot的默认路径不是 "/ ...
- Netty的Marshalling编解码器
1.编码与解码 通常我们习惯将编码(Encode)称为序列化(serialization),它将对象序列化为字节数组,用于网络传输.数据持久化或者其它用途.反之,解码(Decode)称为反序列化 ...
- Git执行"git rebase -i HEAD~xxx"报错:git rebase fatal: Needed a single revision invalid upstream –i
一.问题"git rebase -i HEAD~xxx"是修改git 历史记录的一个很有用的命令. 但是有时在执行该命令时会出现以下错误:$ git rebase –i HEAD~ ...
- Java工具类——日期相关的类
前言 在日常的开发工作当中,我们经常需要用到日期相关的类(包括日期类已经处理日期的类),所以,我就专门整理了一篇关于日期相关的类,希望可以帮助到大家. 正文 一.日期类介绍 在 Java 里面,操作日 ...