I'm using the Node JS Child Process to run a command, I need to somehow automatically enter some text when prompted and press enter automatically from within my stdout, not sure how to do that...
var child = spawn('COMMAND-TO-RUN', {
shell: true
});
child.stdout.on('data', function (data) {
// when prompted in the terminal, need to input something automatically from here...
console.log(data)
console.log("STDOUT:", data.toString());
});
UPDATE
I've already tried to use child.stdin.write and this didn't work in the context of my problem where the terminal is prompting for a SSH password since I'm trying to automate inputting a password into the terminal through the JS, not sure why this doesn't work.

child.stdin.write(stuff to write)stdin.writeappears not to write anything.'\n'to the input does it work? The line feed signifies the submission of the prompt.setTimeoutas wellsshdoesn't read the password from standard input, otherwise something likeecho password | ssh hostwould work. Instead standard input gets passed to the command on the remote side. This may or may not help: serverfault.com/questions/241588/…