Created
November 20, 2009 23:30
-
-
Save jimeh/239876 to your computer and use it in GitHub Desktop.
sudome — A simple Ruby method which checks if the current script is running as root, and if not, re-invokes itself by using the sudo command.
This file contains 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
# A simple Ruby method which checks if the current script | |
# is running as root, and if not, re-invokes itself by | |
# using the sudo command. | |
def sudome | |
if ENV["USER"] != "root" | |
exec("sudo #{ENV['_']} #{ARGV.join(' ')}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment