I am running Windows 10, and I have a program, call her program, which can be launched from the command line. At startup, it responds to commands that the user enters. The user enters a command, presses the return key, and the program prints the response. I did not make this program and do not have a source, therefore I cannot change it.
I want to run this program from Node.js, and my Node.js program acts as a user, sends it and receives answers. I run my program as follows:
var spawn = require('child_process').spawn;
var child = spawn('program');
child.stdout.on('data', function(data) {
console.log(`stdout: ${data}`);
});
Then I try to send him a command, for example help.
child.stdin.write("help\n");
. , help , . , Node.js , , . , stdin.write() , . , , , . ?
, , , , "", .