title: How do I pass variables from ruby to sh command
body: <p>I have a rake task that runs, quite a lot of code. At the end, I need to use sftp and ssh to do some stuff. At the moment I'm unable to automate it. Is there a way to pass to stdout?</p>
  
  <p>This seems like a simple question but I can't find the answer anywhere</p>
  
  <pre><code>#some ruby code
  #more ruby code
  sh "sftp myuser@hots" #this opens the sftp console
  sh "put file" #this doesn't get run until sftp is exited
  sh "put another_file" #neither does this
  
  #more ruby code
  sh "ssh host" # opens the ssh console
  sh "some_action_on_host" # this doesn't get run until ssh is exited    
  </code></pre>
  
  <p>I know there will be ways of doing sftp and ssh using ruby but ideally I just want to be able to pipe variables and commands into the console</p>