Cannot Launch `gksudo` using NodeJs `exec`
Цель
I want to show graphical password prompt in nodejs to elevate priviledge thus gain some power to copy file content into another, but the last is owned by root.
In the implementation, I try to execute dd
along with it's argument with gksudo
с exec()
функция.
exec = require('child_process').exec
printall = function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error) {
console.log('exec err: ' + error);
}
}
exec("gksudo dd if=/home/user/minor.txt of=/home/user/major.txt", printall)
ошибка
But I always fail, with no good reason.
Он сказал,
stdout:
stderr:
exec err: Error: Command failed: /bin/sh -c gksudo dd if=/home/user/minor.txt of=/home/user/major.txt
If I reproduce the command into terminal, it missed double quotes and instead run gksudo
только. Well, in nodejs, it simply fails.
Заметки
I originally develop Atom package. It's my first time, so, I found out about a different version of Node (or IOJs?). I execute the whole code inside Atom.
Вопрос
If you expect a clear question, well, possibly
Как выполнить
gksudo
within node.js to run other command along with the arguments?