Skip to content

Instantly share code, notes, and snippets.

@mudphone
Created July 21, 2010 11:35
Show Gist options
  • Save mudphone/484368 to your computer and use it in GitHub Desktop.
Save mudphone/484368 to your computer and use it in GitHub Desktop.
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