title: ssh script returns 255 error
body: <p>In my code I have the following to run a remote script.</p>
  
  <pre><code>ssh root@host.domain.com "sh /home/user/backup_mysql.sh"
  </code></pre>
  
  <p>For some reason it keeps 255'ing on me. Any ideas?</p>
  
  <p>I can SSH into the box just fine (passless keys setup) </p>
  
  <p>REMOTE SCRIPT:</p>
  
  <pre><code>MUSER='root' 
  MPASS='123123'
  MHOST="127.0.0.1"
  VERBOSE=0
  
  ### Set bins path ###
  GZIP=/bin/gzip
  MYSQL=/usr/bin/mysql
  MYSQLDUMP=/usr/bin/mysqldump
  RM=/bin/rm
  MKDIR=/bin/mkdir
  MYSQLADMIN=/usr/bin/mysqladmin
  GREP=/bin/grep
  
  ### Setup dump directory ###
  BAKRSNROOT=/.snapshots/tmp
  
  #####################################
  ### ----[ No Editing below ]------###
  #####################################
  ### Default time format ###
  TIME_FORMAT='%H_%M_%S%P'
  
  ### Make a backup ###
  backup_mysql_rsnapshot(){
          local DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
          local db="";
          [ ! -d $BAKRSNROOT ] &amp;&amp; ${MKDIR} -p $BAKRSNROOT
          ${RM} -f $BAKRSNROOT/* &gt;/dev/null 2&gt;&amp;1
  #       [ $VERBOSE -eq 1 ] &amp;&amp; echo "*** Dumping MySQL Database ***"
  #       [ $VERBOSE -eq 1 ] &amp;&amp; echo -n "Database&gt; "
          for db in $DBS
          do
                  local tTime=$(date +"${TIME_FORMAT}")
                  local FILE="${BAKRSNROOT}/${db}.${tTime}.gz"
  #               [ $VERBOSE -eq 1 ] &amp;&amp; echo -n "$db.."
                  ${MYSQLDUMP} --single-transaction -u ${MUSER} -h ${MHOST} -p${MPASS} $db | ${GZIP} -9 &gt; $FILE
          done
  #               [ $VERBOSE -eq 1 ] &amp;&amp; echo ""
  #               [ $VERBOSE -eq 1 ] &amp;&amp; echo "*** Backup done [ files wrote to $BAKRSNROOT] ***"
  }
  
  ### Die on demand with message ###
  die(){
          echo "$@"
          exit 999
  }
  
  ### Make sure bins exists.. else die
  verify_bins(){
          [ ! -x $GZIP ] &amp;&amp; die "File $GZIP does not exists. Make sure correct path is set in $0."
          [ ! -x $MYSQL ] &amp;&amp; die "File $MYSQL does not exists. Make sure correct path is set in $0."
          [ ! -x $MYSQLDUMP ] &amp;&amp; die "File $MYSQLDUMP does not exists. Make sure correct path is set in $0."
          [ ! -x $RM ] &amp;&amp; die "File $RM does not exists. Make sure correct path is set in $0."
          [ ! -x $MKDIR ] &amp;&amp; die "File $MKDIR does not exists. Make sure correct path is set in $0."
          [ ! -x $MYSQLADMIN ] &amp;&amp; die "File $MYSQLADMIN does not exists. Make sure correct path is set in $0."
          [ ! -x $GREP ] &amp;&amp; die "File $GREP does not exists. Make sure correct path is set in $0."
  }
  
  ### Make sure we can connect to server ... else die
  verify_mysql_connection(){
          $MYSQLADMIN  -u $MUSER -h $MHOST -p$MPASS ping | $GREP 'alive'&gt;/dev/null
          [ $? -eq 0 ] || die "Error: Cannot connect to MySQL Server. Make sure username and password are set correctly in $0"
  }
  
  ### main ####
  verify_bins
  verify_mysql_connection
  backup_mysql_rsnapshot
  </code></pre>