Conditions in unix ftp script

Viewed 219

I'm trying to write a code that will check a specific date's file and if it exists it'll get it to my local home path and if it doesn't exists then will retrieve other file of different date.

#!/bin/ksh

FILE1="CAS_20170604.txt"
FILE2="CAS_20170603.txt"

/usr/bin/ftp -n 93.45.148.9 << EOF
    user usr passwd
    cd "/abc/def"
    bin
    get $FILE1

if [ ! -f $FILE1 ];
then
    cd "/abc/def"
    bin
    get $FILE2
fi
    bye
    !EOF! 

While on executing the script, I'm getting both the files, which is not required, and the below error:

?Invalid command
?Invalid command

Please someone could help me here.

1 Answers
Related