The list of remote files is witten in a local file. The number of lines of this result file is the remote files count.
Remote_count_file=tmp/ftp_ls.$$
Name of the local file where the list of remote files will be written ($$ rpresent the pid of the process).
rm -f $Remote_count_file
Delete the result file if already exists (variable name error in the original post)
ls . $Remote_count_file
List the files in the remote directory and writes the result in the local file $Remote_count_file (I hope that this syntax is not specific to my AIX system). If the remote directory is empty, the result file is not created.
if [ -f $Remote_count_file ]
Test if the result file exists
then Remote_count=`wc -l <$Remote_count_file | awk '{print $1}'`
The result file exists and contains the list of remote files. The number of lines is the remote file count (the '<' before the file name in the wc command may be omited)
else Remote_count=0
The result file doesn't exist, the remote directory is empty (or ftp error, not checked...)