Created
February 14, 2013 19:57
-
-
Save davidh-raybeam/4955851 to your computer and use it in GitHub Desktop.
A shell function and script to run a command as another user. Invoke as `runas USER COMMAND`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
runas () | |
{ | |
usr=$1; | |
shift; | |
sudo -u $usr /path/to/with_env.sh $@ | |
} | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source ~/.bashrc | |
util=$1 | |
shift | |
$util $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment