【发布时间】:2018-04-19 12:56:37
【问题描述】:
我有一个可用于执行 Rscript 的有效命令,如下所示:
Rscript 02_Meta_Analyses.R --api_es
http://localhost:8071/api/v1/studies/analysisData\?study\=00000000-
0000-4000-0000-000000000000\&study\=00000000-0000-4000-0000-
000000000001\&study\=00000000-0000-4200-0000-000000000000 --uuid
STUDY_ID --author AUTHOR --year YEAR --type_1 GROUP1 --type_2
GROUP2 --pedro PEDRO --api_select
http://localhost:8071/api/v1/analysis/meta-
analysis/5ad8505491951a966b6984fb --uuid_select STUDY_ID --
outbroad_select OUT_BROAD_SELECT
当我将它直接输入到我的 shell 时,这个脚本正在运行
但是,因为参数中的 uuid 是动态生成的。我创建命令字符串并在 child_procee.exec(command) 中使用它,如下所示:
// create the command.
const command = 'Rscript 02_Meta_Analyses.R --api_es
http://localhost:8071/api/v1/studies/analysisData?study\=00000000-
0000-4000-0000-000000000000&study=00000000-0000-4000-0000-
000000000001&study=00000000-0000-4200-0000-000000000000 --uuid
STUDY_ID --author AUTHOR --year YEAR --type_1 GROUP1 --type_2
GROUP2 --pedro PEDRO --api_select
http://localhost:8071/api/v1/analysis/meta-
analysis/5ad8505491951a966b6984fb --uuid_select STUDY_ID --
outbroad_select OUT_BROAD_SELECT'
// execute the command.
const { exec } = require('child_process');
exec(command, options, (error, stdout, stderr) => {
if (error) {
pino.info(`Metadata analysis exec error: ${error}`);
sendFailureEmail(user.email, done);
} else {
........
}
我尽我所能:
例如 1
const command = 'Rscript 02_Meta_Analyses.R --api_es
http://localhost:8071/api/v1/studies/analysisData\\?study\\=00000000-
0000-4000-0000-000000000000\\&study\\=00000000-0000-4000-0000-
000000000001\\&study\\=00000000-0000-4200-0000-000000000000 --uuid
STUDY_ID --author AUTHOR --year YEAR --type_1 GROUP1 --type_2
GROUP2 --pedro PEDRO --api_select
http://localhost:8071/api/v1/analysis/meta-
analysis/5ad8505491951a966b6984fb --uuid_select STUDY_ID --
outbroad_select OUT_BROAD_SELECT
例如 2:
const command = 'Rscript 02_Meta_Analyses.R --api_es
"http://localhost:8071/api/v1/studies/analysisData\\?
study\\=00000000-
0000-4000-0000-000000000000\\&study\\=00000000-0000-4000-0000-
000000000001\\&study\\=00000000-0000-4200-0000-000000000000" --uuid
STUDY_ID --author AUTHOR --year YEAR --type_1 GROUP1 --type_2
GROUP2 --pedro PEDRO --api_select
http://localhost:8071/api/v1/analysis/meta-
analysis/5ad8505491951a966b6984fb --uuid_select STUDY_ID --
outbroad_select OUT_BROAD_SELECT'
但似乎我无法获得可用于执行 R 脚本的有效命令。希望我能澄清我的问题,如果有任何提示,我将不胜感激。
【问题讨论】:
标签: node.js linux bash child-process spawn