ftp, archive, email and delete from shell script

Hello, I found the forum�s information very helpful and informative. I am relatively new to UNIX programming. I am researching how to write a UNIX shell script to ftp all files from specific host folder to a client server. Also need to archive all transferred files, send a message (email) if any file was not transferred successfully and save (email) a log after the script's execution.
Where can find additional information or script�s examples?
Thank you in advance

man ftp
man sendmail
man bash

First, consider reading Classic Shell Scripting book for learning shell scripting...

How can save the ftp transferred details in log ?

Hi everyone
I have a shell script to ftp (2 .gz files) and send some emails with attachments.
Expert opinions welcome! ... Any comments or suggestions would be most welcome.

Here is the script:
#!/bin/bash
# ## use "arc-$(date '+%y%m%d'.%H%M%S)" for prod
##################################################################################
DATE=`date +%Y%m%d`
TIME=`date +%H%M%S`
LOGFILE="process$(date '+%y%m%d')"
MESSAGE1="BACKUP: OK"
MESSAGE2="BACKUP: Fail"
MESSAGE3="GZIP: OK"
MESSAGE4="GZIP: Fail"
vFName="arc-$(date '+%y%m%d')"
mFile="/name1/name2/name3/"

##################################################################################
# ## Create a list of files - filename.txt
##################################################################################
echo "List of files in "$mFile":" >> $LOGFILE.log
ls -1 $mFile >> $LOGFILE.log

##################################################################################
# ## TAR - create a collection of files within a single file uncompressed
# ## check the command execution and save a message (BACKUP: Fail / BACKUP: OK)
# ## exit if the TAR command failed
##################################################################################
tar -cvvf "/name1/name2/name4/$vFName.tar" / name1/name2/name3/*.txt

if [ $? -gt 0 ]; then
echo "BACKUP: Fail"
printf "%-8s %-10s %-6s %-80s\n" $vFName.tar $DATE $TIME "$MESSAGE2" >> $LOGFILE.log
mailx -s "BACKUP: Fail" "ipeleva@zenithadmin.com" < "$LOGFILE.log"
exit
else
echo "BACKUP: OK"
echo " " >> $LOGFILE.log
echo "TAR file SIZE DATE TIME MESSAGE" >> $LOGFILE.log
F1SIZE=`ls -l /impact/conv/arc/$vFName.tar|tr -s " "|cut -d" " -f5`
printf "%-8s %-11s %-10s %-6s %-80s\n" $vFName.tar $F1SIZE $DATE $TIME "$MESSAGE1" >> $LOGFILE.log
fi

###################################################################################
# ## GZIP - compresses the file .tar, making it .tar.gz.
# ## -f force to overwrite if there is a file aready
# ## When doing this the original file will no longer exist on the drive.
# ## check the command execution and save a message (GZIP: Fail / GZIP: OK)
# ## exit if the GZIP command failed
###################################################################################
gzip -f " /name1/name2/name4/$vFName".tar

if [ $? -gt 0 ]; then
echo "GZIP: Fail"
printf "%-8s %-10s %-6s %-80s\n" $vFName.tar.gz $DATE $TIME "$MESSAGE4" >> $LOGFILE.log
mailx -s "GZIP: Fail" "ipeleva@zenithadmin.com" < "$LOGFILE.log"
else
echo "ZIP: OK"
echo " " >> $LOGFILE.log
echo "TAR.GZ file SIZE DATE TIME MESSAGE" >> $LOGFILE.log
F2SIZE=`ls -l /impact/conv/arc/$vFName.tar.gz|tr -s " "|cut -d" " -f5`
printf "%-8s %-8s %-10s %-6s %-80s\n" $vFName.tar.gz $F2SIZE $DATE $TIME "$MESSAGE3" >> $LOGFILE.log
fi

FILE1IN="/name1/name2/name4/$vFName.tar.gz"
FILE1OUT="$vFName.tar.gz"
FILEIN1SIZE=`ls -l $FILE1IN|tr -s " "|cut -d" " -f5`

FILE2IN="/name1/name2/name4/$vFName.tar.gz"
FILE2OUT="$vFName.tar.gz"
FILEIN2SIZE=`ls -l $FILE2IN|tr -s " "|cut -d" " -f5`

###################################################################################
# User and host info
###################################################################################
HOST=host.com'
FTPUSER='user'
PASSWD='password'
HOSTDIR='/nameh1/nameh2'

###################################################################################
# Upload to ftp
# ftp.log - all ftp messages
###################################################################################
ftp -v -n $HOST > / name1/name2/name4/ftp.log <<EOF
quote user $FTPUSER
quote pass $PASSWD
cd �/nameh1/nameh2'"
bin
put $FILE1IN $FILE1OUT
put $FILE2IN $FILE2OUT
EOF

###################################################################################
# Check the ftp status and file
# ## wc -l tells the number of lines (accounts)
###################################################################################
ftp_ctr=`cat / name1/name2/name4/ftp.log | grep 226 | wc -l`

if [ "$ftp_ctr" = 2 ]; then
echo "No Error"
echo "List of transferred files:" >> ./transfer.txt
printf "System:Impact\tRemote:$HOST\tRemote Folder:$HOSTDIR\tFile Name:$FILE1OUT\tFile Size:$FILEIN1SIZE\n" >> ./transfer.txt
printf "System:Impact\tRemote:$HOST\tRemote Folder:$HOSTDIR\tFile Name:$FILE2OUT\tFile Size:$FILEIN2SIZE\n" >> ./transfer.txt
FILENAME="transfer.txt"
else
echo "Error has occured"
echo "List of transferred files:" >> ./error.txt
printf "System:Impact\tRemote:$HOST\tRemote Folder:$HOSTDIR\tFile Name:$FILE1OUT\tFile Size:$FILEIN1SIZE\n" >> ./error.txt
printf "System:Impact\tRemote:$HOST\tRemote Folder:$HOSTDIR\tFile Name:$FILE2OUT\tFile Size:$FILEIN2SIZE\n" >> ./error.txt
FILENAME="error.txt"
fi

mailx -s "FTP log" "name@somewhere.com" < "$LOGFILE.log"
email_dest=$(grep $FILENAME filelist.txt|cut -d ";" -f 2;)
mailx -s "FTP " "$email_dest" < "$FILENAME"