verify ftp status is "good"

Hello,
From reading prior "threads", my script looks like this:

#!/bin/ksh -x
ftpresults=`ftp -nv $ftphost1 << EOB
user $ftpuser $ftppwd
put $ftp_file $ft
put $ftp_file $ft1
bye
EOB`
ftp_ctr=`echo $ftpresults | grep "226 Transfer complete" | wc -l`
echo $ftp_ctr
If [ $ftp_ctr = 2 ]
then
...
else
...
fi

I want to make sure that I have successfully ftp'd two files. The $ftp_ctr returns 1; while it should be 2. Any ideas why this code only returns 1 and not 2. I ftp'd two files, there are two instances of "226 Transfer complete" in the variable $ftp_ctr.

Also, is there a better way to check for a successful ftp?

Thanks in advance for your help! This site is great!

I'm betting that because you are putting all the information into a variable, that it is all one line - since you are counting how many LINES have the successful transfer, it's only 1 everytime (although there are two occurances in the one line).

The other problem is if you ftp to a site that has a huge banner before you ever do a login, all of that is saved into your variable. Possible that you would overload it and your script would bomb out and you would never know why.

Try double quotes around the results:
ftp_ctr=`echo "$ftpresults" | grep "226 Transfer complete" | wc -l`

Thank you - it works!

remote_file_size=`grep $file file.log | awk ' { print $5 } '`
local_file_size=`l | grep $file | awk ' { print $5 } '`

echo "CHECKING TRANSFER"
echo "remote size $remote_file_size local size $local_file_size"
if [ $remote_file_size = $local_file_size ] ; then
echo "TRANSFER WAS SUCCESSFUL!"
mail -s "File Transfer Complete" jamison < ftp.log
/otl/otlcap/bin/cdpager 0011
fi
if [ $remote_file_size != $local_file_size ] ; then
echo "TRANSFER FAILED!"
mail -s "File Transfer Failed" jamison < honda_ftp.log
/otl/otlcap/bin/cdpager 0010

i grep the file size on both their system and mine, compare them all, then i echo out a message, email me a message, and also page me. when dealing with 400+ meg files its nice to be alerted no matter where i am