title: Rails application to run commands on remote machine
body: <p>I have a Ruby on Rails 3 application, that I would like to control a remote machine via SSH access.</p>
  
  <p>Basically I would like the Rails application to be able to edit files, copy them, move directories, etc. on a remote machine via SSH.</p>
  
  <p>I have already created Capistrano tasks for the functions I would like to execute, but I would like to know:</p>
  
  <ol>
  <li>What is the best practice of running remote shell code from Rails</li>
  <li>How can I invoke Capistrano tasks from a Rails application (which would basically achieve 1)</li>
  </ol>
  
  <p>Thanks!</p>