I am stuck on a NodeJS error while trying to execute a script and get the output of it.
I get the following error :
TypeError: invalid data
at WriteStream.Socket.write (net.js:623:11)
at Object.execFileSync (child_process.js:482:20)
at doRender (/test/apps/application/routes/TEST.js:1786:26)
I guess it comes from a misuse of the NodeJS native execFileSync
function, but I've tried a lot of things to match the documentation without any success so far.
Here is my code :
router.get("/stat", authReader, function (req, res) {
//Current file is in application/routes
var doRender = function (req, res) {
var output;
//I want to execute application/scripts/test.bash
output= child_process.execFileSync("test.bash",[], {
cwd: "../scripts"
});
result= processDataFromCSV(output);
//processing data in response
res.render(acronym + "_test", {
title: "CSV output",
result: result,
});
}
doRender(req, res);
}
Could you please help me to understand what I am doing wrong ? Any help is greatly appreciated.