child-process

Node.js child_process.spawn is unable to launch python process

狂风中的少年 提交于 2021-01-27 18:44:24
问题 I have written following code to spawn a python process. I am able to launch other processes but not python. I tried reinstalling python and node but still no luck. I am able to run python from command line. Please help. const spawn = require("child_process").spawn; var process = spawn('python',[ 'D:/python_script.py']); var responseData = ""; process.stdout.setEncoding('utf-8'); process.stdout.on('data', function (data){ responseData += data.toString(); }); process.stdout.on('end',function

How to avoid command injection in node child_process exec

谁说我不能喝 提交于 2021-01-07 03:01:29
问题 I am opening IE browser in(via) my electron application using Node child_process . Code below: var cp = require('child_process'); var browser = cp.exec('start', 'iexplore', ['-private', args.url]); This is raising command injection warning when I run Fortify analysis on this code. Also, this args.url is fetched from api resource (stored in db) and is not related to any user input on this client application. Please help me escape this. I also tried spawn , but no success. 回答1: As a rule of

Saving the output of a child process in a variable in the parent in NodeJS

血红的双手。 提交于 2020-12-29 13:15:20
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible

Saving the output of a child process in a variable in the parent in NodeJS

那年仲夏 提交于 2020-12-29 13:12:25
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible

Saving the output of a child process in a variable in the parent in NodeJS

纵饮孤独 提交于 2020-12-29 13:08:27
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible