Created
July 21, 2010 11:35
-
-
Save mudphone/484368 to your computer and use it in GitHub Desktop.
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
module Remote | |
def remote(host, cmd, no_sudo=false) | |
ssh_cmd = "ssh #{host}" | |
ssh_cmd += " sudo bash" unless no_sudo | |
cmd = %Q[echo "#{cmd}"|#{ssh_cmd}] | |
p "Running: #{cmd}" | |
system cmd | |
end | |
end | |
# Use it like this: | |
class MyClass | |
include Remote | |
remote "server1.com", "pwd; id; for i in {1..9}; do echo \\$i chunky bacons; sleep 1; done" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment