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 版本,进行不同的兼容性处理. 没想到看似简单的需求,中间也经历了一番波折,好在最后解决了问题. 在此记录一下解决问题的过程,也方便其他有类 ...
随机推荐
- python+selenium上传本地文件
迅雷号自媒体视频文件自动上传,贴标签发布 难点 本地文件上传,通过send_keys(‘文件路径’)的方式实现上传的目的 文件名通过正则匹配的方式进行处理,主要匹配出中文标题名称 处理过程中文件名称中 ...
- (五)使用logback进行日志记录
原文:https://www.cnblogs.com/taiyonghai/p/9290641.html 引入jar包 此处如果是引用了spring boot则不需要再引一下的jar包了,spring ...
- 【Spring注解驱动开发】在@Import注解中使用ImportBeanDefinitionRegistrar向容器中注册bean
写在前面 在前面的文章中,我们学习了如何使用@Import注解向Spring容器中导入bean,可以使用@Import注解快速向容器中导入bean,小伙伴们可以参见<[Spring注解驱动开发] ...
- 用VC++6.0,双击主对话框中的按钮时,不能跳转到代码处
1. 首先在项目中--[生成]build--[清除解决方案]clean 2. 关闭项目 3. 删除项目中的[Debug]下所有文件 4. 把*.aps,*.clw,*.ncb,*.opt删掉----- ...
- 无法解析的外部符号 "public: virtual struct CRuntimeClass * _
SetupPropertyPage.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct CRuntimeClass * __this ...
- SFTP协议生成公共秘钥文件
[步骤] 1 ssh方式登录服务器 2 执行命令生成秘钥对 ssh-keygen -t rsa 然后给秘钥文件命名 3.查看当前目录的.ssh目录是否有authorized_keys文件 如果有则把新 ...
- PHP利用FTP上传文件连接超时之开启被动模式解决方法
初始代码: <?php $conn = ftp_connect("localhost") or die("Could not connect"); ftp ...
- JavaWeb网上图书商城完整项目--day02-11.激活功能流程分析
1.当用户注册成功之后,会给用户发送邮件,当用户点击邮件的激活按钮的时候,会调用UserServlet中的activation的方法,并且会把激活码传递到后台,后台业务层对业务进行操作
- JavaWeb网上图书商城完整项目--day02-26.查询所有分类功能之DAO层实现
我们按照表示的设计 以及: package com.weiyuan.goods.category.domain; import java.util.List; public class Categor ...
- 面试官:你刚说你喜欢研究新技术,那么请说说你对 Blazor 的了解
阅读本文大概需要 1.5 分钟. 最近在几个微信 .NET 交流群里大家讨论比较频繁的话题就是这几天自己的面试经历. 面试官:"你刚说你喜欢研究新技术,那么你对 Blazor 了解多少?&q ...