Reputation: 110093
How would I do the following in a shell script?
$ su my_user
Password: my_password
This is required, as I need to install homebrew
on a mac, and it won't allow me to install it under sudo
, but requires that I have admin privileges.
$ sudo /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
Password:
Don't run this as root!
And why I can't run this as a current user (who is not an admin) -
$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
This script requires the user to be an Administrator. If this
sucks for you then you can install Homebrew in your home directory or however
you please; please refer to our homepage. If you still want to use this script
set your user to be an Administrator in System Preferences or `su' to a
non-root user with Administrator privileges.
It is not an option to be logged in as an admin to run the script, I must su
in the script.
Upvotes: 0
Views: 2533
Reputation: 56049
On a mac, there is a difference between root
and an administrator. Administrator roughly translates to the wheel
group on a standard Unix/Linux system, meaning those in the "administrators" group can gain elevated privileges using their password (à la sudo). Make sure the user under which you're trying to run this is an administrator: click on the apple menu in the upper left-hand corner, System Preferences, Users & Groups. It should say "Admin" under your name; if it doesn't, that's your problem. Click on the lock (bottom left of the window), put in the username and password of an administrator account on the machine, click on your user, then check the "Allow user to administer this computer" box.
Upvotes: 2
Reputation: 538
you would need to do it from a outside a shell, like bash or ssh or telnet , managed by 'expect' try
man expect
or for a short introduction http://en.wikipedia.org/wiki/Expect
Upvotes: 0