I am trying to use a child process that involves using sudo.
It works fine in terminal:
sudo /home/pi/Desktop/fm_transmitter/bin/Release/fm_transmitter high_dash.wav 103.50
However, when i try it as a child process:
const execFile = require('child_process').execFile;
const child =execFile('sudo /home/pi/Desktop/fm_transmitter/bin/Release/fm_transmitter', ['high_dash.wav 103.50'] ,(error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});
}
I get the following error:
/home/pi/Desktop/fm_transmitter/execFile.js:71 throw error; ^
Error: spawn sudo /home/pi/Desktop/fm_transmitter/bin/Release/fm_transmitter ENOENT
How can i incorporate sudo into a child process?
Thanks