如何在 MEAN 堆栈中执行 shell 命令行?
How can I execute shell command line in MEAN stack?
你好,我是 MEAN 堆栈的新手。
之前我用php做web开发,一般都是用"shell_exec"浏览服务器json文件,阅读
如何在 MEAN 堆栈中执行 shell 命令行?
MEAN 堆栈中的 "shell_exec" 是什么?
提前致谢:)
如果您需要浏览json - 就简单多了:
const data = require('./some-file.json');
如果您还需要 exec,这里是:
const { exec } = require('child_process');
exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
你好,我是 MEAN 堆栈的新手。
之前我用php做web开发,一般都是用"shell_exec"浏览服务器json文件,阅读
如何在 MEAN 堆栈中执行 shell 命令行?
MEAN 堆栈中的 "shell_exec" 是什么?
提前致谢:)
如果您需要浏览json - 就简单多了:
const data = require('./some-file.json');
如果您还需要 exec,这里是:
const { exec } = require('child_process');
exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});