SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:

function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let count=1
let limit=16
while [[ $count -le 16 ]]
do
        IFS=","
        set ${ABP_HOST_CONFIG}
        while [[ $# -gt 0 ]]
        do
  #         if [ "$count" -eq "$limit" ]; then
                HostVar="HOST_${count}=$1"
                UserVar="ACCOUNT_${count}=$2"
                PassVar="PASSWORD_${count}=$ABP_DEV_PASS"
                echo $HostVar
                echo $UserVar
                echo $PassVar
                read
                let count=count+1
                FTGSTR="$HostVar;$UserVar;$PassVar"
                shift;shift
#       done
                writeRecord ${PREFIX}FTG FTP SYSDATE NULL NULL NULL NULL NULL ${HOST} ${FTGSTR} NULL NULL N ${MARKET} NULL NULL
                echo  ${PREFIX}FTG FTP SYSDATE NULL NULL NULL NULL NULL ${HOST} ${FTGSTR} NULL NULL N ${MARKET} NULL NULL


        done
#done
#       writeRecord ${PREFIX}FTG FTP SYSDATE NULL NULL NULL NULL NULL ${HOST} ${FTGSTR} NULL NULL N ${MARKET} NULL NULL
        unset IFS
done
}

If you add a 'set -x' command at the top of your function, it will generate trace output which should show you exactly where things are going wrong. If you can't figure it out from that, paste that output for us. Naturally, if there is sensitive information involved, mask it in a way that protects it without altering the usefulness of the trace.

function InsertFtg
{
set -x
FTGSTR=""
...

Regards,
Alister

Hi Alister this is the WriteRecord Fun....

function writeRecord
{

cat >> $ins_sql << EOWP
prompt inserting '${1}' '${2}'
INSERT INTO GN1_CONNECT_PARAMS ( CONNECT_CODE, SERVER_TYPE, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE,
 DL_UPDATE_STAMP, HOST_NAME, CONN_PARAMS, PASSWORD, DB_USER_TYPE, DB_USER_XMKT_IND, DB_USER_MKT, DB_COMPLEX_NAME, USER_LEVEL )
VALUES ( '${1}', '${2}', ${3}, ${4}, ${5}, ${6}, ${7}, ${8}, '${9}', '<Parameters>', ${11}, ${12}, '${13}', '${14}', ${15}, ${16});

EOWP

counter=0
IFS=";"
for i in ${10}
do
        cat >> $ins_sql << EOU
UPDATE GN1_CONNECT_PARAMS SET CONN_PARAMS=CONN_PARAMS`convertXml ${i}` WHERE CONNECT_CODE='${1}';

EOU
if [[ ${counter}%10 -eq 0 ]]
then
        print -n ". "
fi
let counter=counter+1
done


cat >> $ins_sql << EOWR
UPDATE GN1_CONNECT_PARAMS SET CONN_PARAMS=CONN_PARAMS||CHR(10)||'</Parameters>' WHERE CONNECT_CODE='${1}';
commit;
EOWR
unset IFS
}

This is O/P after running script with set -x

Processing, please wait...

. . . . . REF SNAPSHOT B
. . . . J2EE/INFRA SECTION
. . . . . . for _partition in 0001 0002 0003 0004 0099
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AFG GD oracle
AFG GD oracle 1
. . AFG GD oracle 2
. . AFG GD oracle 3
. . AFG GD oracle 4
. . test
AFG GD oracle 5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + InsertUsq
. . . . + InsertFtg
+ FTGSTR=
+ echo Saurabh is GREAT 0
Saurabh is GREAT 0
+ let count=1
+ [[ 1 -le 16 ]]
+ IFS=,
+ set indibm007 velwrk53
+ [[ 2 -gt 0 ]]
+ HostVar=HOST_1=indibm007
+ UserVar=ACCOUNT_1=velwrk53
+ PassVar=PASSWORD_1=Test11!
+ echo HOST_1=indibm007
HOST_1=indibm007
+ echo ACCOUNT_1=velwrk53
ACCOUNT_1=velwrk53
+ echo PASSWORD_1=Test11!
PASSWORD_1=Test11!
+ read
+ let count=count+1
+ FTGSTR=HOST_1=indibm007;ACCOUNT_1=velwrk53;PASSWORD_1=Test11!
+ writeRecord VELFTG FTP SYSDATE NULL NULL NULL NULL NULL indibm007 HOST_1=indibm007;ACCOUNT_1=velwrk53;PASSWORD_1=Test11! NULL NULL N VEL NULL NULL
. + shift
+ shift
+ [[ 0 -gt 0 ]]
+ echo VELFTG FTP SYSDATE NULL NULL NULL NULL NULL indibm007 HOST_1=indibm007;ACCOUNT_1=velwrk53;PASSWORD_1=Test11! NULL NULL N VEL NULL NULL
VELFTG FTP SYSDATE NULL NULL NULL NULL NULL indibm007 HOST_1=indibm007;ACCOUNT_1=velwrk53;PASSWORD_1=Test11! NULL NULL N VEL NULL NULL
+ [[ 2 -le 16 ]]
+ IFS=,
+ set indibm007 velwrk53
+ [[ 2 -gt 0 ]]
+ HostVar=HOST_2=indibm007
+ UserVar=ACCOUNT_2=velwrk53
+ PassVar=PASSWORD_2=Test11!
+ echo HOST_2=indibm007
HOST_2=indibm007
+ echo ACCOUNT_2=velwrk53
ACCOUNT_2=velwrk53
+ echo PASSWORD_2=Test11!
PASSWORD_2=Test11!
+ read

+ let count=count+1
+ FTGSTR=HOST_2=indibm007;ACCOUNT_2=velwrk53;PASSWORD_2=Test11!
+ writeRecord VELFTG FTP SYSDATE NULL NULL NULL NULL NULL indibm007 HOST_2=indibm007;ACCOUNT_2=velwrk53;PASSWORD_2=Test11! NULL NULL N VEL NULL NULL
. + shift
+ shift
+ [[ 0 -gt 0 ]]
+ echo VELFTG FTP SYSDATE NULL NULL NULL NULL NULL indibm007 HOST_2=indibm007;ACCOUNT_2=velwrk53;PASSWORD_2=Test11! NULL NULL N VEL NULL NULL
VELFTG FTP SYSDATE NULL NULL NULL NULL NULL indibm007 HOST_2=indibm007;ACCOUNT_2=velwrk53;PASSWORD_2=Test11! NULL NULL N VEL NULL NULL
+ [[ 3 -le 16 ]]
+ IFS=,
+ set indibm007 velwrk53
+ [[ 2 -gt 0 ]]
+ HostVar=HOST_3=indibm007
+ UserVar=ACCOUNT_3=velwrk53
+ PassVar=PASSWORD_3=Test11!
+ echo HOST_3=indibm007
HOST_3=indibm007
+ echo ACCOUNT_3=velwrk53
ACCOUNT_3=velwrk53
+ echo PASSWORD_3=Test11!
PASSWORD_3=Test11!
+ read

like this it's coming until counter becomes 16
So Please Advise ASAP.... My work is Stuck......