title: Capture exit code for remote script?
body: <p>I have a shell script that runs on my server every day. It does some house cleaning and connects to a remote host to perform other tasks i.e.</p>
  
  <pre><code>#!/bin/bash
  
  #do something...
  ...locally...
  
  #run remote script...
  ssh user@remotehost "/opt/process/verify.sh"
  
  exit
  </code></pre>
  
  <p>It works fine but to be safe I would like to capture (if possible) the return code from "/opt/process/verify.sh" i.e. </p>
  
  <ul>
  <li>if fail, return "1" and send email to admin </li>
  <li>if success, return "0" and send email to developer.</li>
  </ul>
  
  <p>I started reading about the command <code>trap</code>. Can I use it for that purpose? Is there another option?</p>