I'm designing a little software in Java. I don't know the term/definition to what I'm doing, but I'm prompting commands from Java to the terminal. Something like this:
Process process = Runtime.getRuntime().exec("command");
I've done this before in Linux, and I used gksudo
for commands that required the root password.
Is there any gksudo
in OS X? Any graphical popup asking for root password?
By default, Mac OS X includes the admin group in the sudoers file and gives that group authorization to run any command with sudo . Mac OS X accounts given administrator privileges become members of the admin group, and thereby receive complete sudo privileges.
The Mac Terminal is a command line interface (CLI) for the macOS operating system (OS). Mac Terminal is typically used by network administrators and advanced technical users who want to initiate an action that is not supported by the operating system's graphical user interface (GUI).
You can more ore less manage to write your own with an AppleScript shell script:
#!/bin/sh osascript -e "do shell script \"$*\" with administrator privileges"
cocoasudo
looks aesthetically more pleasing, but this is already deployed.
This also looks promising: cocoasudo
It uses the OSX native Authorization Services API:
For Mac OS X Cocoa-based apps, there is analagous ability to sudo provided via the Authorization Services API. Use of the API allows you to prompt the user for their username and password requesting the ability to escalate privileges.
…
For that case, I’ve written a small utility that I’ve dubbed cocoasudo. Use cocoasudo in much the same way you’d use sudo. However, instead of users being prompted for their password in a Terminal window, they’ll get a dialog prompt via the Authorization Services API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With