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 版本,进行不同的兼容性处理. 没想到看似简单的需求,中间也经历了一番波折,好在最后解决了问题. 在此记录一下解决问题的过程,也方便其他有类 ...
随机推荐
- <WP8开发学习笔记>修改panorama全景控件的标题的大小
panorama(全景)控件非常具有WinPhone特色,但是那个巨大的标题许多时候会让人觉得违和.怎么修改它呢? 最开始想到的是加一个FontSize,结果毫无影响.╮(╯-╰)╭ <phon ...
- Eureka加了secsecurity后注册失败
报错信息: com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known ...
- C#数据结构与算法系列(五):常见单链表笔试
1.求单链表中有效节点个数 public static int GetLength(HeroNode headNode) { int length = ; var cur = headNode.Nex ...
- 带你学够浪:Go语言基础系列 - 8分钟学复合类型
★ 文章每周持续更新,原创不易,「三连」让更多人看到是对我最大的肯定.可以微信搜索公众号「 后端技术学堂 」第一时间阅读(一般比博客早更新一到两篇) " 对于一般的语言使用者来说 ,20% ...
- 阿里P7终于讲完了JDK+Spring+mybatis+Dubbo+SpringMvc+Netty源码
前言 这里普及一下,每个公司都有职别定级系统,阿里也是,技术岗以 P 定级,一般校招 P5, 社招 P6 起.其实阅读源码也是有很多诀窍的,这里分享几点心得: 首先要会用.你要知道这个库是干什么的,掌 ...
- 【asp.net core 系列】13 Identity 身份验证入门
0. 前言 通过前两篇我们实现了如何在Service层如何访问数据,以及如何运用简单的加密算法对数据加密.这一篇我们将探索如何实现asp.net core的身份验证. 1. 身份验证 asp.net ...
- 线程基础8-quene讲解
PriorityBlockingQueue是一个基于优先级堆的无界的并发安全的优先级队列(FIFO),队列的元素按照其自然顺序进行排序,或者根据构造队列时提供的 Comparator 进行排序,具体取 ...
- 慕课网 性能优化之MySQL优化--- max 和count的性能优化
注:在执行SQL语句前加上explain可以查看MySQL的执行计划 数据库:MySQL官方提供的sakila数据库 Max优化: 例如:查询最后支付时间 explain select max(pay ...
- 发布Nuget包时遇到都意外
准备好工具和发布教程.(这些网上都有,我就不说了,就说说我遇到都意外.) 在发布包都过程中,我给我都dll命名为Common.不知道是不是这个原因导致的我包发布上去后,程序对其引用时居然没主动引用进程 ...
- Celery浅谈
一.Celery 核心模块 1. Brokers brokers 中文意思为中间人,在这里就是指任务队列本身,接收生产者发来的消息即Task,将任务存入队列.任务的消费者是Worker,Brokers ...