I am getting strange message when run borne shell script

I have a code:

 if [ -d ${COOLDIR}/cool_${Today}/daily ]
then#{ process daily files
 for file in *_${Today}*.csv *_${Today}*.txt
do
        if [ -f "LET_daily_trans_${Today}.csv" ] || [ -f "LET_daily_trans_345_${Today}.csv" ]
        then
                echo "This file will be processed in separate script"
                continue
        fi
         if [ "${prefix}" = "MBSE_daily_trans_sum_" ];then
                                sftp_name=MBSEDTRNSUM
                        elif [ "${prefix}" = "MBSE_daily_trans_badcpn_" ];then
                                sftp_name=MBSEDTRNBADCPN
                        elif [ "${prefix}" = "MBSE_daily_trans_sum_345_" ];then
                                sftp_name=MBSEDTRNSUM345
                        elif [ "${prefix}" = "MBSE_daily_trans_badcpn_345_" ];then
                                sftp_name=MBSEDTRNBADCPN345
                        elif [ "${prefix}" = "MBSE_daily_trans_" ];then
                                sftp_name=MBSEDAYTRNS
                        elif [ "${prefix}" = "MBSE_daily_trans_345_" ];then
                                sftp_name=MBSEDAYTRNS345
                        else
                                echo "Unnkowned prefix name ${prefix}"
           fi
           if [ "${ext}" != "txt" ];then
                     do something
           fi

 done
 
for file in *.${Today}*.csv *.${Today}*.txt
do
  if [ -f daily_tba_position.${Today} ] || [ -f daily_pool_position.${Today} ] || [ -f LET.${Today} ];then
                echo "files were processed by the brkvol_day_sftp_ondemand.sh script"
                continue
  fi
 if [ "${ext}" != "txt" ]
  then
     do something
               if [ "${fldt}" = "-" ];then
                          do something
               else
                  do something
               fi
        do something
    else
          do something
    fi
 if [ "${ext}" != "txt" ];then
          do something                     
                                
 else
           do something                     
  fi

 done
 fi #} finished to process daily files line 384

When I try to run the borne shell script I am getting message

 ./sftp_ondemand.sh[95]: syntax error at line 384 : `fi' unexpected
 

Could you please let me know why?

Thanks for contribution

Not knowing what a borne shell is, I suspect this

then#{ process daily files

to be the culprit. Trying to replicate the problem (like then#blalala ), in bash I get

bash: syntax error near unexpected token `fi'

while in sh (dash), I get

sh: 1: Syntax error: "fi" unexpected (expecting "then")

which is way more enlightening than the error message that you received from your shell.

By the way, proper and consistent indenting always helps to reveal problems in code blocks due to missing / unclosed keywords or tokens (if - fi, case - esac, do - done, "(" - ")", etc. )

1 Like

That is perfectly works. It is bourne shell , Sorry