||03-29-2009 03:38 PM
Running a command as another user in a bash script ran as root?
Hello all! I've written a short bash script for use when I'm at home that brings a network interface up, sets a few options, and starts a few programs. This needs to be run as root so that DHCP can be configured correctly, etc. It works great, but the problem I've run into is not being able to run a shell command as another user from within the bash script.
echo `su greg | mpdscribble && exit`
This is what I have right now, and it does start mpdscribble, but I have to manually exit out of the su part before the rest will finish. Is there an easier way to go about this, or is my grammar just wrong?