Skip to content

Instantly share code, notes, and snippets.

@jimeh
Created November 20, 2009 23:30
Show Gist options
  • Save jimeh/239876 to your computer and use it in GitHub Desktop.
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.
# 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