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.
Here $Nelement is the ftp server IP $protocol is ftp
#!/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 <<EOS
                        quote USER $user
                        quote PASS $pass
                mkdir -p $dir
                cd $dir
                mput $newFileName
                bye
        EOS`
                else
                        `$protocol $user@$Nelement <<EOS
                        bye
        EOS`
                fi
        done
The error that I receive is
+ '[' 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
