title: Running part of bash script on a remote machine
body: <p>I need to run some commands locally and then some command on a remote machine all using a single local bash script.</p>
  
  <p>For simplicity just say I want to do the following and execute it on my local desktop machine.</p>
  
  <pre><code>#!/bin/bash
  
  #upload some files to a remote machine
  cd /tmp
  ./upload-files.sh
  
  #run commands on remote machine
  ssh myuser:mypass@somewhere.com
  cd /tmp/uploads    &lt;--- these commands don't run in the ssh connection
  ./process-uploads.sh
  exit
  
  #run command locally again.
  cd -
  echo 'complete!'
  </code></pre>
  
  <p>Any ideas of how to do this?</p>