I need to programmatically open a shell script in a Terminal window and run it with administrator privileges. I'm using osascript as it displays a convenient prompt for an admin login/password.
I'm currently using this :
osascript -e 'do shell script "open -a Terminal \"'"$appDir"'\"" with administrator privileges'
The trouble is, even after entering the credentials in the OS X prompt, the newly opened script will beg for a password at the first sudo command.
How do I pass the admin credentials to the opened script?
Best Answer
I'd try writing a simple script:
save this as
something.command
, change its permissions to executable withchmod +x
, and then run this from AppleScript withInstead of
/usr/bin/id
you can call whatever script you need to run with admin privileges then.EDIT:
This will work: