Alex Rivera | Logout

Is there any graphical "sudo" for Mac OS X?

Asked 2009-10-04T19:29:23.370
27

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?

Edit
Report

2 Answers

6

I found the cocoasudo doesn't work if you are running a shell script that calls other commands. You would have to use cocoasudo in all sub-commands also which would pop up a prompt for each call.

The osascript solution seems to work better, but I needed to tweak it to work with commands involving paths containing spaces.

#!/bin/sh
export bar=""
for i in "$@"; do export bar="$bar '${i}'";done
osascript -e "do shell script \"$bar\" with administrator privileges"
answered 2010-06-14T02:11:07.267
2

gksudo is the GTK+ version of sudo.

You can use this clone for it especially for OS X.

answered 2009-10-04T19:34:38.390

Your Answer