How do I use node.js child_process to programatically allow me to supply a password.
const spawn = require('child_process').spawn;
const ls = spawn('sudo ls');
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
The above throws an error. I am trying to figure out where exactly I can catch where it is wanting the password input and supply that via an environment variable.
I am hoping I can catch when it says Password check to make sure its saying that and then pass the password.