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.
from Node JS spawn input text when prompted
No comments:
Post a Comment