I am using osascript in a BASH script for dialog boxes on a MAC system. The problem I am having is several of the commands I need to use require privilages to function correct. If I use sudo in the BASH script, the password prompt shows in the terminal window. Is the some way I can hook the sudo password prompt into an osascript dialog box? Or is there a different way I can handle asking for the password in an osascript dialog box and passing it to some other program to handle it?
Asked
Active
Viewed 2,210 times
0
-
See [this Apple.SE question](http://apple.stackexchange.com/questions/23494/what-option-should-i-give-the-sudo-command-to-have-the-password-asked-through-a). – Gordon Davisson Feb 27 '15 at 03:47
2 Answers
3
What worked for me was to create the BASH script and then use osascript to call it.
$ osascript -e 'do shell script "/Path/yourbashscript.sh" with administrator privileges'
This will prompt a dialog box straight from Apple's infrastructure. Same one you see when you're asked for your username & password.
You can run this in terminal or use a third-party wrapper like, Platypus

James Dean
- 155
- 1
- 17
0
You can suppress the password interface by modifying your Mac's authorization rights.
Use the built-in security command line tool or authbuddy to change the system.preferences.accessibility right to allow:
sudo security authorizationdb write system.preferences.accessibility allow
Opening up the system.preferences.accessibility right will permit any user to change the accessibility settings without a password prompt.

MisterPatate
- 287
- 1
- 2
- 16
-
Unfortunatly this script is going to be given to customesrs, so modifying their system preferences is not an option I want them to enter thier password., but I want to use an osascript dialog box to do it, and not in the terminal window, like it is currently working – Dennis Kerrisk Feb 26 '15 at 21:17