Execute a command as sudo from within a rake task?
Other than hard-coding "sudo" into the exec/system argument string, is there a flag in Rake that specifies that a command needs to be executed with root privileges, and will prompt for a password if needed? Like how Babushka has a :sudo => true
开发者_如何转开发 option.
don't know if there's a Rake option for this (but I suppose there isn't). you can easyly do it by checking user's privileges. check this answer:
On Unix, find if user who executed the program is root?
精彩评论