title: OSX bash script works but fails in crontab on SFTP
body: <p>this topic has been discussed at length, however, I have a variant on the theme that I just cannot crack. Two days into this now and decided to ping the community. THx in advance for reading.. </p>
  
  <p>Exec. summary is I have a script in OS X that runs fine and executes without issue or error when done manually. When I put the script in the crontab to run daily <strong>it still runs</strong> but it doesnt run all of the commands (specifically SFTP).</p>
  
  <p>I have read enough posts to go down the path of environment issues, so as you will see below, I hard referenced the location of the SFTP in the event of a PATH issue...</p>
  
  <p>The only thing that I can think of is the IdentityFile. NOTE: I am putting this in the crontab for my user not root. So I understand that it <em>should</em> pickup on the id_dsa.pub that I have created (and that has already been shared with the server).. </p>
  
  <p>I am not trying to do any funky expect commands to bypass the password, etc. I dont know why when run from the cron that it is skipping the SFTP line.</p>
  
  <p>please see the code below.. and help is greatly appreciated.. thx</p>
  
  <pre><code>#!/bin/bash
  export DATE=`date +%y%m%d%H%M%S`
  export YYMMDD=`date +%y%m%d`
  PDATE=$DATE
  YDATE=$YYMMDD
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  FEED="~/Dropbox/"
  
  USER="user"
  HOST="host.domain.tld"
  
  A="/tmp/5nPR45bH"
  
  &gt;${A}.file1${PDATE}
  &gt;${A}.file2${PDATE}
  
  BYEbye ()
  {
  rm ${A}.file1${PDATE}
  rm ${A}.file2${PDATE}
  
  echo "Finished cleaning internal logs"
  exit 0 
  }
  
  
  echo "get -r *" &gt;&gt; ${A}.file1${PDATE}
  echo "quit" &gt;&gt; ${A}.file1${PDATE}
  
  eval mkdir ${FEED}${YDATE}
  eval cd ${FEED}${YDATE}
  
  
  eval /usr/bin/sftp -b ${A}.file1${PDATE} ${USER}@${HOST}
  
  BYEbye
  exit 0
  </code></pre>