MCPcopy
hub / github.com/dqzboy/Docker-Proxy / execCommand

Function execCommand

hubcmdui/server-utils.js:17–31  ·  view source on GitHub ↗

* 安全执行系统命令 * @param {string} command - 要执行的命令 * @param {object} options - 执行选项 * @returns {Promise } 命令输出结果

(command, options = { timeout: 30000 })

Source from the content-addressed store, hash-verified

15 * @returns {Promise<string>} 命令输出结果
16 */
17function execCommand(command, options = { timeout: 30000 }) {
18 return new Promise((resolve, reject) => {
19 exec(command, options, (error, stdout, stderr) => {
20 if (error) {
21 if (error.killed) {
22 reject(new Error('执行命令超时'));
23 } else {
24 reject(error);
25 }
26 return;
27 }
28 resolve(stdout.trim() || stderr.trim());
29 });
30 });
31}
32
33/**
34 * 获取系统信息

Callers 4

getCpuInfoFunction · 0.85
getDiskInfoFunction · 0.85
system.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected