Problem while execution of second set of commands

Hi,
I have a shell script with code
. perf.env
cd $QRY_DIR
for SHELL_FILE in sql1
do
export SNAME=$SHELL_FILE
${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} &
RC=$(expr ${RC:-0} + $? )
sleep 60
if [ $RC == 0 ]
then
echo sysdate>test1
echo query1.txt>>test1
grep -i selected sql_test.txt>>test1
grep -i elapsed sql_test.txt>>test1
awk '/rows selected/ { $0=$1 } /Elapsed/ { split($2, t, ":");$0=3600*t[0]+60t[1
]+'t[2]+.001
t[3]' }{ out=out sprintf("%s%s",NR==1?"":",","\047"$0"\047") }END{
print("insert into FDW_QUERY_TIME values ("out");") }' test1>test2
fi
done
exit $RC

My problem is after executing the sql1 and the spooling is completed I want to execute the next bit of code after sleep.I actually want to grep the spooled file items.but before spooling is completed the command are executed.
Can any one help me to correct this

Remove the trailing & on the sql execution line. remove sleep as well.

Jim,
it worked.But I have one more doubt
My Elapsed time is Elapsed: 00:00:26.42
So in seconds i should get 26.042 second.but as per this code I am getting
it as 0.02642.
Can you please tell me where I have made a mistake.

Thanks

$0=3600*t[0]+60*t[1]+'t[2]+.001*t[3]

The first piece of the array is stored in t[1] not in t[0].

Regards

Franklin,
thanks my problem is solved

I have further a problem with my code.
. perf.env
cd $QRY_DIR
for SHELL_FILE in sql1 sql2
do
export SNAME=$SHELL_FILE
${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME}
RC=$(expr ${RC:-0} + $? )

if [ $RC == 0 ]
then
sel1='/selected/{p;q;}'
sel2='/Elapsed/{p;q;}'
for i in *.txt
do
TZ=`date +%Z` ; a=`date +%d-%b-%y`
echo $a >$i_1
echo 1 >>$i_1
sed -n $sel1 $i >>$i_1
sed -n $sel2 $i >>$i_1

awk '/rows selected/ { $0=$1 } /Elapsed/ { split($2, t, ":");$0=3600*t[1]+60*t[2]+t[3] }{ out=out sprintf("%s%s",NR==1?"":",","\047"$0"\047") }END{ print(""out"") }' $i_1>$i_1_r
done
fi
done
exit $RC

I am getting error
unknown echo command....
and also while printing the out I do not want single quotes but need the fields seperated by commas only.
And also I want to sqlldr user/pwd control=f1.ctl data=$i_1_r (i.e I want the $i_1_r files to be loaded to database)

Please help me ..

thread can be closed