title: Calling a Bash function in a while loop
body: <p>I made this script which checks to make sure that an offshore script is created. I works ok &emdash; I put in a function to make it a little cleaner. But I don't think that the function works because it keeps on printing out the same time, in seconds. </p>
  
  <pre><code>#!/bin/bash
  #set -x
  check_offshore ()
  {
      local RESULTS
      RESULTS=$(ssh -q -T casper@mybox "ls -ltr  /come/and/play/with/us/danny/DropBox| grep foreverr_and_$today.csv")
      rc=$?
  }
  
  today=$(/bin/date +%Y%m%d)
  time=$(/bin/date +"%T.%3N")
  iterate=0
  while [ $iterate -le 5 ]
  do
       check_offshore
       if [[ $rc != 0 ]] ; then
          echo "$time foreverr_and_$today.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox"
          fi
       sleep 5
       iterate=$((iterate+1 ))
       done
  </code></pre>
  
  <p>This is the log that it creates &emdash; the log time never changes. It stays the same, forever and ever and ever until the script stops. </p>
  
  <pre><code>17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
  17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
  17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
  17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
  17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
  17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
  </code></pre>
  
  <p>What's up and how do I fix it?</p>