Created
September 2, 2013 20:29
-
-
Save sintaxi/6416999 to your computer and use it in GitHub Desktop.
trying to spawn a child process as root user without being prompted in main script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test by running `node test.js` | |
var spawn = require("child_process").spawn | |
var child = spawn("sudo", [__dirname + "/bin/server"]) | |
child.stderr.on('data', function (data) { | |
child.stdin.write("somepassword" + '\n'); | |
}) |
Unfortunately, this doesn't work anymore (Mac Catalina) :/
Tried on Big Sur, still working.
Did not work on Monterey (12.0.1). I added the "-S" flag to the beginning of the args array and that fixed it. const child = spawn("sudo", ["-S","-k","echo","Hello"])
Per this man page
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately, this doesn't work anymore (Mac Catalina) :/