Module: CommandKit::Sudo
Overview
Allows running commands with sudo
.
Instance Attribute Summary
Attributes included from OS
Instance Method Summary collapse
-
#sudo(command, *arguments) ⇒ Boolean?
Runs the command under sudo, if the user isn't already root.
Methods included from OS
#bsd?, #freebsd?, #initialize, #linux?, #macos?, #netbsd?, #openbsd?, #unix?, #windows?
Methods included from OS::ModuleMethods
Instance Method Details
#sudo(command, *arguments) ⇒ Boolean?
Runs the command under sudo, if the user isn't already root.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/command_kit/sudo.rb', line 28 def sudo(command,*arguments) if windows? system('runas','/user:administrator',command,*arguments) else if Process.uid == 0 system(command,*arguments) else system('sudo',command,*arguments) end end end |