I compiled a piece of CPP code to generate a file that (getpsdata), can run alone (. / getpsdata). Now I want to run this file in node to get the relevant output data and results in the code. I use the following code:
var spawn = require ("child_process"). Spawn;
var ps = spawn (". / getpsdata", {stdio: ["pipe"," pipe", "pipe"]});
if (ps.stdout! = = null) {
ps.stdout.on("data", function(data) {
console.log("data", data.toString());
});
} else {
console.log(ps.stdout);
}
/ / ps.stdout.on ("data", function (data) {
/ / console.log (" data", data.toString ());
/ /});
if (ps.stderr! = = null) {
ps.stderr.on("data", function(data) {
console.log("data", data.toString());
});
} else {
console.log(ps.stderr);
}
/ / ps.stderr.on ("data", function (data) {
/ / console.log (" error", data.toString ());
/ /});
ps.on ("close", function (code) {
console.log (" close", code);
});
ps.on ("exit",function (code) {
)console.log("exit", code);
});
ps.on ("error", function (code) {
console.log (" error", code);
});
after my execution, the console does not have any output results. What should I do if I get the data printed or output in the getpsdata execution in the node program now?