If, elif, else statements help

I am in need of some help. I am not an advance scripter or programmer, I have novice knowledge. I cannot get a script to work as expected. The script basically does an FTP (which I have work perfectly) and writes to a log. However, I want the script to echo "Not Connected" if the FTP fails to connect (checks log and sees not connected errors) or echo "Successfully Connected" if the FTP transmits successfully (status code equals 0) or "Error" if the script fails for any other reason (any other status code except 0).

if grep "Not Connected" $LOG
then
    echo "Not Connected"

elif [ $? -eq 0 ]
then    
    echo "Successfully Connected"
    
else
    echo "Error, please review"

fi

Can anyone tell me what I'm doing wrong with the if, elif, else statements above? The script runs without error, but only the last is echoed "Error, please review" regardless if it completes successfully or not. Please help. Thanks.

Every command sets $?. You are expecting $? to be the status of the last command that interests you. Immediately after the command you want do status=$? and later you can check $status. But I'm also worried that you are checking the return code of ftp. Are you sure that your version of ftp will set the return code you expect? The ftp process may think it worked correctly even if a disered file was not present.

Thanks for replying.

So basically to check the status of FTP using $? I'll need to check that immediately after FTP quits to be sure it exited properly? FYI, I am using Cygwin and the default FTP. Here is the entire code,

#!/bin/bash
FILE=SOMETHING.zip
LOG=SOMETHING.log

ftp -vin <<-ENDFTP
open ftp.SOMETHING.com
user SOMEUSER SOMEPASSWD
bin
prompt off
put $FILE 
disconnect
quit
ENDFTP

if grep "Not Connected" $LOG
then
    echo "Not Connected"

elif [ $? -eq 0 ]
then    
    echo "Successfully Connected"
    
else
    echo "Error, please review"

fi

echo $?

So how can I logically get this code working properly to check all three conditions? Thanks.

---------- Post updated at 11:25 AM ---------- Previous update was at 11:07 AM ----------

Thanks to your insight @Perderabo I got the script working as expected. I completely nix the exit status statement and replaced it with a grep in the log for "Transfer complete". Now the code is working properly. Thank you.

Here's an example of the working code,

#!/bin/bash
FILE=SOMETHING.zip
LOG=SOMETHING.log

ftp -vin <<-ENDFTP
open ftp.SOMETHING.com
user SOMEUSER SOMEPASSWD
bin
prompt off
put $FILE 
disconnect
quit
ENDFTP

if grep "Not Connected" $LOG
then
    echo "Not Connected"

elif grep "Transfer complete" $LOG
then    
    echo "Successfully Connected"
    
else
    echo "Error, please review"

fi

echo $?