title: Bash script to move files ftp server fails
body: <p>I have a bunch of files in a folder that I want to move into a new folder in an ftp server.
  I am able to log in to the ftp server with the following code but I get an error while trying to create and move the file into the ftp server after logging in.</p>
  
  <p>Here $Nelement is the ftp server IP 
  $protocol is ftp</p>
  
  <pre><code>#!/bin/sh
  
          cat $ftpFile | while read LINE
          do
                  user=`echo $LINE | awk -F":" '{print $1}'`
                  pass=`echo $LINE | awk -F":" '{print $2}'`
                  protocol=`echo $LINE | awk -F":" '{print $3}'`
                  Nelement=`echo $LINE | awk -F":" '{print $4}'`
  
                  if [ "$protocol" = "ftp" ]; then
                          `$protocol -n $Nelement &lt;&lt;EOS
                          quote USER $user
                          quote PASS $pass
                  mkdir -p $dir
                  cd $dir
                  mput $newFileName
                  bye
          EOS`
  
                  else
                          `$protocol $user@$Nelement &lt;&lt;EOS
                          bye
          EOS`
                  fi
          done
  </code></pre>
  
  <p>The error that I receive is </p>
  
  <pre><code>+ '[' ftp = ftp ']'
  sc.sh: line 38: warning: here-document at line 31 delimited by end-of-file 
  (wanted `EOS')
  + Create directory operation failed. Failed to change directory. mput 
  'testfile.txt?' '?Invalid' command
  sc.sh: line 31: Create: command not found
  </code></pre>