I have an little problem here. I have nodejs app that should run command in OS's bash with root rights, f.e.
Command is: echo "$password" | /usr/bin/sudo /usr/bin/abc --key "$username"
Here is my code:
const spawn = require('child_process').spawn;
function sendMessage() {
let username = 'WhoLetTheDogsOut';
let password = 'Woof!';
const echo = spawn('echo', [ password ]);
const abc = spawn('sudo', [ `/usr/bin/abc --key ${username}` ]);
}
sendMessage();
Please, help. I didn't get where I'm wrong after reading official Node child_process.spawn() doc and I'm keep getting error: gnokii stderr: sudo: /usr/bin/gnokii --sendsms +375293941196: command not found
/usr/bin/abc --key ${username}? Shouldn't they be '.