Hello,
I have a problem with my script whereby it does not want to loop.
The function of my script is to FTP into a server and go to each directory/volume in the array 'VOL'. The way the loop is suppose to work, is to go into the first volume, get the files of R(yesterday's date) and save them in another server .. 'REPOSITORY' and then move on to the other volume in the array.
The problem with my script is that it does not loop. It just runs in the first directory then ends.
if [ $# -ne 1 ]
then
DAISAGO=1
else
DAISAGO=$1
fi
YESTERDAY=`date -d ${DAISAGO}day+ago +%y%m%d`
REPOSITORY=/home/CDR-backups
cd $REPOSITORY
VOL=(D010AMAB D000AMAA D010AMA9 D000AMA8 D010AMA5 D000AMA6 D010AMA7 D000AMA4 D010AMA3 D000AMA2 D010AMA1 D000AMA0)
ftp -n ##.##.##.## << !EOF
user ****** ******
binary
lcd $REPOSITORY
for VOL in ${VOL[@]}
do
cd /$VOL
pwd
dir
mget R${YESTERDAY}*
done
bye
Below is the output after running my script.
CDR:/home # ./getama.sh
Connected to ##.##.##.##
220 Welcome to Bla Bla Bla
331 Password required.
230 User logged in, proceed
Remote system type is SOS.
200 Command okay.
Local directory now /home/CDR-backups
usage: for format
?Invalid command.
200 Directory changed.
257 Current working directory is "/D010AMAB"
500 Syntax error, command unrecognized.
227 Entering Passive Mode (##,##,##,##,11,186)
150 File status okay; about to open data connection.
DIRP_FILESEG FIXED 2048 ********
DIRP_FILESEG FIXED 2048 ********
DIRP_FILESEG FIXED 2048 ********
226 Request successful. Closing data connection.
?Invalid command.
221 Service closing control connection.
Can someone please help me.
Please and thanks.