Hello All,
I am having a problem with an �if loop� within a �while loop� in my Korn Shell program. The basic concept of the program is that it searches for the existence of a series of load files in a load directory, and once it finds one of these files, it begins the following process:
� Creates a status configuration file in a specified directory.
� Performs a prompt less ssh of the file to a load status directory in another database.
� Initializing a Korn Shell program based on the name file to create a db2 table and to load that table with information contained in the file.
� Deletes the loaded file from the load directory
� Initializing a �ssh� to remove the previously transferred file from the load status directory in the other database.
This process is repeated until all of the designated files have been processed. In order to automate this process I used a �while loop�, a series of �if loops�, an �until loop�, and two arrays-one containing the name and location path for the for the files that are expected to be found in the load directory and one containing the name and location path of the Korn Shell programs that will create the required tables and that will load these files into these tables.
The issue that I am having is that I am receiving the following error as it relates to one of my �if loops�:
0403-057 Syntax error at line 166: `fi' is not expected.
From examining the code, it seems that the syntax is correct (a �fi� to close every �if loop�). Any help that you give me in solving this problem will be appreciated. The code is as follows:
+130 #initializing counter
+131
+132 i=0
+133
+134 #looping through loadfile array
+135
+136 while [[ $tableloadcnt -le ${#loadfile
[*]} ]] ; do
+137 if [[ -a ${loadfile} ]] ; then
+138 echo "${loadfile}"
+139 echo "$i"
+140 echo "$tableloadcnt"
+141 print "$(date) : $fcntcdm .del file waiting to be loaded on DDWTST0. "
+142 echo "$(date): Creating the status cofiguration file to be transfered to $LOAD_STATUS_DIR on DDW0."
+143 touch $STAT_CONFIGI_DIR_DDWTST0/$FTPINI_DDW0
+144 RC=$?
+145 if [[ $RC -ne 0 ]] ; then
+146 print "$(date) : An error occured during the rename processs: Error code $RC"
+147 exit $RC
+148 else
+149 echo "$(date): $STAT_CONFIGI_DIR_DDWTST0/$FTPINI_DDW0 has been cretated. "
+150 echo "$(date "+%H:%M:%S") - Initializing promptless transfer of status configuration file to $FTPHOST_DDW0"
+151 scp -p $STAT_CONFIGI_DIR_DDWTST0/$FTPINI_DDW0 $FTPHOST_DDW0:$LOAD_STATUS_DIR/
+152 echo "$(date "+%H:%M:%S") : $FTPINI_DDW0 has been tranferred to $LOAD_STATUS_DIR on $FTPHOST_DDW0"
+153 fi
+154 ${loadfile}
+155 RC=$?
+156 if [[ $RC -ne 0 ]] ; then
+157 print "$(date) : An error occured during the execution of ${loadfile} : Error code $RC "
+158 exit $RC
+159 else
+160 print "$(date) : ${loadfile} has been successfully executed : Return Code $RC "
+161 ((tableloadcnt+=1)
+162 echo "$(date) : The number of tables created and load is : $tableloadcnt"
+163 rm -f ${loadfile}
+164 ssh $FTPHOST_DDW0 "rm -f $LOAD_STATUS_DIR/$FTPINI_DDW0"
+165 fi
+166 else
+167 until [[ -a ${loadfile} ]] ; do
+168 ((direcnt+=1))
+169 print "$(date) : the mount directory is empty : $direcnt loop count."
+170 sleep 10
+171 done
+172 fi
+173 ((i+=1))
+174 done