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 版本,进行不同的兼容性处理. 没想到看似简单的需求,中间也经历了一番波折,好在最后解决了问题. 在此记录一下解决问题的过程,也方便其他有类 ...
随机推荐
- 在Asp.NET Core中如何优雅的管理用户机密数据
在Asp.NET Core中如何优雅的管理用户机密数据 背景 回顾 在软件开发过程中,使用配置文件来管理某些对应用程序运行中需要使用的参数是常见的作法.在早期VB/VB.NET时代,经常使用.ini文 ...
- ping外网:unknown host www.baidu.comc排查
ping 百度出现:(ping www.baidu.com) "ping: unknown host www.baidu.com" 1.ping 网关确定是否连接上路由器,并 ...
- MATLAB读取和保存nifti文件
介绍 分析核磁数据时,数据的读取和保存是两个基本的操作.虽然大部分工具包都对这些功能进行了封装,但是如果你不了解如何使用这些工具包或者说当前的任务太简单不值得去使用这些庞大的工具包的时候就需要我们自己 ...
- 使用LaTeX输入矩阵
当前各种文本编辑器支持的LaTeX数学公式库大多基于KaTeX,或者在Web中用MathJax的比较多,下面给出一种在Web中输入矩阵的例子 $$\left[ \begin{array}{cccc}a ...
- 开源一款超实用的 Dubbo 测试工具,已用半年,感觉很有feel~
不知道你是否在工作中有遇到过类似情况: dubbo接口调试复杂,需要通过telnet命令或者通过consumer调用来触发. telnet语句参数格式复杂,每次编写都要小心谨慎,一旦出错又需重来. 复 ...
- MFC时间简单比较方法
MFC//时间简单比较方法 void CMFCsaveListTofileDlg::OnBnClickedButton6()//时间简单比较方法 { // TODO: 在此添加控件通知处理程序代码 C ...
- Python实用笔记 (8)高级特性——迭代
如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代(Iteration). 比如dict就可以迭代: >>> d = {'a ...
- webstom 汉化,激活
1.激活 本地服务器激活: 下载 magnet:?xt=urn:btih:2289E4F8CEB346AC44E54C8C0DA706CC537301AA 得到一个压缩包IntelliJIDEALic ...
- dart快速入门教程 (7.3)
7.4.抽离类为单独文件 新建一个文件,单独存放一个类,例如:Person类抽离到person.dart文件中 class Person { final String name; final num ...
- Python进阶之浅谈内置方法
目录 有序or无序和可变or不可变 数字类型内置方法 整形 浮点型 字符串类型内置方法 有序or无序和可变or不可变 有序:有索引 无序:无索引 可变:变量值变,id不变 不可变:变量值变,id也变 ...