Error in UNIX script

When i run a script in linux. It shows the following error.

'icsftpagent.sh: line 114: syntax error near unexpected token `'icsftpagent.sh: line 114: `Nicsftp() The script is as follows.
#!/bin/bash 
#### Copyright Notice: 
#### 
#### Copyright (c) 2007 Network Intelligence Corporation 
#### 
#### Warning: This computer program is protected by copyright law and 
#### international treaties.  Unauthorized reproduction or distribution 
#### of this program, or any portion of it, may result in severe civil 
#### and criminal penalties, and will be prosecuted to the maximum 
#### extent possible under the law. 
#### 
#### RSA, The Security Division of EMC - Automated FTP/SCP/SFTP Script v2.7.11 
#### 
################### 
#### 
####   Begin User configuration 
#### 
########## 
######## 
###### 
#### 
#SILENT MODE 
#produce no output to the console;  
#set this to true when running from cron 
#to reduce emails sent to root. 
SILENT=true 
# Have the Solaris POSIX compliant binaries first in the path. 
# The /usr/bin directory in Solaris doesn't have POSIX compliant 
# binaries. This is particularly a problem for the awk command we are 
# using. (ECE-138) 
#PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/css/bin:$PATH 
## Enter the hostname/IP address of the enVision machine to which you want to 
## send the data files 
ENVISION=192.168.1.20 
## Enter the directories where the data files, which you need to send, exist.  Separate 
## multiple directories with a colon (:).  This script must have read permissions 
## to the directories. 
## Example for multiple folders DATA_DIRECTORY=/var/log/:/var/log/audit 
DATA_DIRECTORY=/var/log/ 
## The directory on the enVision box where the files should be written to.  This directory 
## is relative to the enVision/ftp_files directory.  If the directory name contains a 
## space it will need to be double escaped.  For example, if the directory name is 
## "name with spaces", the variable needs to be set to "name\ with\ spaces". 
ENVISION_DIRECTORY=Squid_192.168.1.63 
## The script keeps its persistent information in a directory.  The 
## script must have read and write permissions to this directory. 
NIC_DIRECTORY=/usr/local/nic 
## TRANSFER_METHOD=SFTP/SCP/FTP 
## Select the method used to transfer the files to enVision.  SFTP is recommended. 
## valid options are FTP, SFTP and SCP 
TRANSFER_METHOD=SFTP 
## Enter a username (ftp default: anonymous; SFTP/SCP default: nic_sshd) 
USERNAME=nic_sshd 
## Enter a password (anonymous connections accept any password) 
PASSWORD=RSAlab@12345 
## Enter the identity/private key file for the user specified above user 
## default is $HOME/.ssh/id_rsa 
IDENTITY=~/.ssh/id_rsa 
## Enter the file matching specification.  "*" will send any files in the directory. Separate 
## multiple fielnames with a colon (:). 
## Example for multiple files::  
## FILESPEC=*.log:xyz.log 
FILESPEC=access.log 
## Enter the file extension of uploaded files 
UPLOAD_SPEC=tmp 
## A value of "no" leaves the file intact after the transfer has occurred. 
## This should be set to "no" if you intend to manage the cleanup/archiving 
## of the original log data  with another process. 
FLAG_REMOVE_FILE_AFTER_SEND=no 
## The ftp or sftp client returns no error code if the transfer fails.  We assume the client 
## will return one (1) line (stating the local directory has changed).  If the client 
## you are using returns a different line count upon successful completion, then enter 
## that number here.  (You will most likely not need to change this.) 
NUMBER_OF_OUTPUT_LINE_ON_SFTP_SUCCESS=6 
## Enter 1 for Solaris, 3 for Red Hat 
NUMBER_OF_OUTPUT_LINE_ON_FTP_SUCCESS=1 
##  CONFIG FILE 
## Optionally define a config file that will override any settings made in this file. 
## This file must be located in the $NIC_DIRECTORY folder as defined in this script. 
NIC_CONFIG=nicsftpagent.conf 
## Script Name.  Used to make sure only one copy of the script is running. 
## If this script is renamed, change this setting to match. 
SCRIPT_NAME="nicsftpagent.sh" 
## Number of seconds to delay before terminating a job. This should be long enough 
## to allow transfer of your largest log files.  The script will update its activity between 
## each file copy.  If another instance is launched it will kill the original if it.s been this  
## many seconds since the original update in the running indicator file. 
KILL_RUNNING_AFTER=300 
## This script supports 2 version of tail.  The script will automaticaly determin the version  
## to use.  To force the use of one of the versions you can change this option. 
## 0 - automatic 
## 1 - tail +10 file 
## 2 - tail --lines=+10 file 
USETAIL=0 
## This script supports including the header in all log files.  This feature was added 
## in order to support the Oracle File System Audit log files. 
## 0 - feature disabled 
## 14 - header support for Oracle 
USEHEAD=0 
#### 
###### 
######## 
########## 
############ 
############ End User configuration 
############ 
################################################################################ 
################################################################################ 
#                                                                               
#                         DO NOT EDIT BELOW THIS LINE                           
#                                                                               
################################################################################ 
################################################################################ 
Nicsftp() 
{ 
                if ["x$SILENT" = "x" ] 
                then 
                    echo "**** Reading new data from $d/$i" 
                fi 
 
                # Support for use of headers - added version 2.7.3 
                if [ $USEHEAD -gt 0 ] 
                then 
                    head --lines $USEHEAD "$d/$i" > "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                    TMPCOUNT=`expr $TMPCOUNT - $USEHEAD` 
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** Re-writing file header." 
                    fi 
                else 
                if [ "x$SILENT" = "x" ] 
                    then 
                    echo "**** Skipping file header." 
                    fi 
                fi 
 
                # Support for different version of tail 
                if [ "x$USETAIL" = "x0" ] 
                then 
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** Automatic tail syntax checking.  You may see an error that can be ignored." 
                    fi 
                    tail +1 "$d/$i" >/dev/null 2>/dev/null 
                    if [ $? -gt 0 ] 
                    then  
                        USETAIL=2 
                    else 
                        USETAIL=1 
                    fi 
                    if [ "x$SILENT" = "x" ] 
                    then 
                            echo "**** Use tail syntax $USETAIL." 
                    fi 
                fi 
                if [  "x$USETAIL" = "x1" ] 
                ## Conditions to check to see if file has already been read - version 2.7.3 
                then 
                    if [ -f "$NIC_DIRECTORY$d/$i-nic.last.line" ] 
                        then 
                            tail +$LAST "$d/$i" >> "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                        else 
                            tail +$LAST "$d/$i" > "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                    fi 
                else 
                    if [ -f "$NIC_DIRECTORY$d/$i-nic.last.line" ] 
                        then 
                            tail --lines=+$LAST "$d/$i" >> "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                        else 
                            tail --lines=+$LAST "$d/$i" > "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                    fi 
                    if [ $? -gt 0 ] 
                    then 
                        echo "**** Critical failure when running tail" 
                        # exit script now. 
                        # clean up running files 
                        rm -f "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                        if [ "x$SILENT" = "x" ] 
                        then 
                            echo "**** removing running files" 
                        fi 
                        if [ -f "$NIC_DIRECTORY/running$ENVISION" ] 
                        then 
                            rm -f "$NIC_DIRECTORY/running$ENVISION" 
                        fi 
 
                        if [ -f "$NIC_DIRECTORY/running$ENVISION.pid" ] 
                        then 
                            rm -f "$NIC_DIRECTORY/running$ENVISION.pid" 
                        fi 
                        exit 1 
                    fi 
                fi 
 
                TMPCOUNT=`wc -l "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" | awk '{print $1}'` 
                ## Added for version 2.7.3 
                if [ -f "$NIC_DIRECTORY$d/$i-nic.last.line" ] 
                then 
                    TMPCOUNT=`expr $TMPCOUNT - $USEHEAD` 
                fi 
 
                ################################################### 
                #     No Transfer Option   
                ################################################### 
                if [ "$TRANSFER_METHOD" = "xNONE" ] 
                then 
                    echo "**** Generated $NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC (Transfer disabled)" 
                ################################################### 
                #     FTP Transfer Option 
                ################################################### 
                elif [ "x$TRANSFER_METHOD" = "xFTP" ] 
                then 
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** Beginning FTP transfer of $d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                    fi 
 
                    ftp -n $ENVISION > "$NIC_DIRECTORY/transfer.output" 2> "$NIC_DIRECTORY/transfer.stderr" <<END1 
                    quote USER $USERNAME 
                    quote PASS $PASSWORD 
                    lcd "$NIC_DIRECTORY$d" 
                    cd "$ENVISION_DIRECTORY" 
                    put "$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC$GZ" 
                    quit 
END1 
                    if [ `wc -l "$NIC_DIRECTORY/transfer.output" | awk '{print $1}'` -gt $NUMBER_OF_OUTPUT_LINE_ON_FTP_SUCCESS ] 
                    then 
                        if [ "x$SILENT" = "x" ] 
                        then 
                            echo "**** There may have been errors during the transfer:(" 
                        fi 
 
                        cat "$NIC_DIRECTORY/transfer.output" 
                        TRANSFER_ERRORS=yes 
                    fi 
                ################################################### 
                #  SFTP  Transfer Option 
                ################################################### 
                elif [ "x$TRANSFER_METHOD" = "xSFTP" ] 
                then 
                    echo lcd \"$NIC_DIRECTORY$d\" > "$NIC_DIRECTORY/sftp.in" 
                    echo cd \"$ENVISION_DIRECTORY\" >> "$NIC_DIRECTORY/sftp.in" 
                    echo put \"$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC$GZ\" \"$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC$GZ\" >> $NIC_DIRECTORY/sftp.in 
                    echo quit >> $NIC_DIRECTORY/sftp.in 
                    sftp -b "$NIC_DIRECTORY/sftp.in" -oIdentityFile="$IDENTITY" $USERNAME@$ENVISION  > "$NIC_DIRECTORY/transfer.output" 2> "$NIC_DIRECTORY/transfer.stderr" 
 
                    if [ $? != "0" ] 
                    then 
                        echo "**** Error detected during transfer:" 
                        echo "" 
                        cat "$NIC_DIRECTORY/transfer.output" 
                        cat "$NIC_DIRECTORY/transfer.stderr" 
                        echo "" 
                        TRANSFER_ERRORS=yes 
                    fi 
 
                    if [ `wc -l "$NIC_DIRECTORY/transfer.output" | awk '{print $1}'` -gt $NUMBER_OF_OUTPUT_LINE_ON_SFTP_SUCCESS ] 
                    then 
                        echo "**** There may have been errors during the transfer:" 
                        echo "" 
                        cat "$NIC_DIRECTORY/transfer.output" 
                        cat "$NIC_DIRECTORY/transfer.stderr" 
                        echo "" 
                        TRANSFER_ERRORS=yes 
                    fi 
                ################################################### 
                #  SCP Transfer  Option 
                ################################################### 
                elif [ "x$TRANSFER_METHOD" = "xSCP" ] 
                then 
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** Beginning SCP transfer of $d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                    fi 
 
                    /usr/bin/scp -i "$IDENTITY" "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC$GZ" $USERNAME@$ENVISION:\"$ENVISION_DIRECTORY\"/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC$GZ > "$NIC_DIRECTORY/transfer.output" 2> "$NIC_DIRECTORY/transfer.stderr" 
                    if [ $? != "0" ] 
                    then 
                        if [ "x$SILENT" = "x" ] 
                        then 
                            echo "**** Error detected during SCP transfer:" 
                        fi 
 
                        cat "$NIC_DIRECTORY/transfer.output" 
                        TRANSFER_ERRORS=yes 
                    fi 
                else 
                    echo "No Transfer Method Selected. ($TRANSFER_METHOD)" 
                    TRANSFER_ERRORS=yes 
                fi 
                ################################################### 
                #  Transfer Complete 
                ################################################### 
 
                if [ "x$SILENT" = "x" ] 
                then 
                    echo "**** Removing temporary data file $i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                fi 
 
                rm -f "$NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
 
                if [ "$TRANSFER_ERRORS" = "yes" ] 
                then 
                    echo "**** Transfer Errors processing $NIC_DIRECTORY$d/$i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC" 
                    echo "**** Exiting Script" 
                    mv -f "$NIC_DIRECTORY/transfer.output" "$NIC_DIRECTORY/transfer.output.lasterr" 
                    mv -f "$NIC_DIRECTORY/transfer.stderr" "$NIC_DIRECTORY/transfer.stderr.lasterr" 
 
                    # clean up running files 
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** removing running files" 
                    fi 
 
                    if [ -f "$NIC_DIRECTORY/running$ENVISION" ] 
                    then 
                        rm -f "$NIC_DIRECTORY/running$ENVISION" 
                    fi 
 
                    if [ -f "$NIC_DIRECTORY/running$ENVISION.pid" ] 
                    then 
                        rm -f "$NIC_DIRECTORY/running$ENVISION.pid" 
                    fi 
 
                    if [ -f "$NIC_DIRECTORY/waiting$ENVISION" ] 
                    then 
                        rm -f "$NIC_DIRECTORY/waiting$ENVISION" 
                    fi 
                    exit 1 
                else 
                    NEWLINE=`expr $LAST + $TMPCOUNT` 
                     
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** Updating file line count previous count: $LAST new count: $NEWLINE" 
                    fi 
 
                    echo "$NEWLINE" > "$NIC_DIRECTORY$d/$i-nic.last.line" 
 
                                        touch "$NIC_DIRECTORY$d/$i-nic.last.time" 
 
                    if [ "x$FLAG_REMOVE_FILE_AFTER_SEND" = "xyes" ] 
                    then 
                        if [ "x$SILENT" = "x" ] 
                        then 
                            echo "**** Removing Log File $i" 
                        fi 
                        rm -f "$i" 
                    fi 
 
                    mv -f "$NIC_DIRECTORY/transfer.output" "$NIC_DIRECTORY/transfer.output.last" 
                    mv -f "$NIC_DIRECTORY/transfer.stderr" "$NIC_DIRECTORY/transfer.stderr.last" 
                fi 
} 
 
###  Get config file if it exists; overrides anything set above. 
if [ -f "$NIC_DIRECTORY/$NIC_CONFIG" ] 
then 
    . "$NIC_DIRECTORY/$NIC_CONFIG" 
 
    if [ "x$SILENT" = "x" ]  
    then  
        echo "Loaded config file $NIC_DIRECTORY/$NIC_CONFIG" 
    fi 
 
elif [ -f "$NIC_CONFIG" ] 
then 
    . "$NIC_CONFIG" 
 
        if [ "x$SILENT" = "x" ]  
    then  
        echo "Loaded config file $NIC_CONFIG" 
    fi 
fi 
################################################# 
# If a copy of the script is running.  exit now.# 
################################################# 
if [ -f "$NIC_DIRECTORY/running$ENVISION" ] 
then 
    if [ "x$SILENT" = "x" ] 
    then 
        echo "A file exists indicating an instance of the script" 
        echo "is already running.  If the script has not updated" 
        echo "this file in $KILL_RUNNING_AFTER seconds, this original" 
        echo "process will be stopped." 
    fi 
 
    RUNNING=`cat "$NIC_DIRECTORY/running$ENVISION" 2>/dev/null` 
    #WAITING=`date +%s` 
    #Bug 112031 
    WAITING=`perl -e 'print time(),"\n"'` 
    DIFF=`expr $WAITING - $RUNNING` 
 
    if [ $DIFF -gt $KILL_RUNNING_AFTER ] 
    then 
        if [ "x$SILENT" = "x" ] 
        then 
            echo "The previous script has not responded in $DIFF" 
            echo "seconds.  If it is still running we will attempt to stop it." 
        fi 
 
        rm -f "$NIC_DIRECTORY/running$ENVISION" 
        # kill the pid now. 
        OLDPID=`cat "$NIC_DIRECTORY/running$ENVISION.pid" 2>/dev/null` 
 
        if [ `ps -aef | grep $OLDPID | grep $SCRIPT_NAME | wc -l | awk '{print $1}'` -gt 0 ] 
        then 
            if [ "x$SILENT" = "x" ] 
            then 
                echo "This script running on PID $OLDPID is inactive and being killed." 
            fi 
            kill -9 $OLDPID 
        fi 
    else 
        if [ "x$SILENT" = "x" ] 
        then 
            echo "The previous instance was active $DIFF seconds ago." 
            echo "This instance will exit now." 
        fi 
 
        exit 0; 
    fi 
fi 
 
TIMENAME=`date +%Y%m%d%H%M%S` 
 
################################################# 
# what are we going to do 
################################################# 
 
if [ "x$SILENT" = "x" ] 
then 
    echo "*******************************************************" 
    echo "****    Time: $TIMENAME" 
    echo "****    Data Directory(s): $DATA_DIRECTORY" 
    echo "****    NIC Directory: $NIC_DIRECTORY" 
    echo "****    enVision: $ENVISION" 
    echo "****    envision Directory: $ENVISION_DIRECTORY" 
    echo "*******************************************************" 
fi 
### Test that NIC directory exists 
if [ ! -d "$NIC_DIRECTORY" ] 
then 
    echo "$NIC_DIRECTORY cannot be found." 
    exit 1 
fi 
PWD=`pwd` 
### Test that each of the data directories exists 
for d in `echo "$DATA_DIRECTORY" | awk '{split($0, a, ":"); for (i in a) print a; }'` 
do 
    if [ ! -d $d ] 
    then 
        echo "$d cannot be found." 
        exit 1 
    elif [ -d "$NIC_DIRECTORY$d" ] 
    then 
        # Clear out old tracking files 
         
        cd "$NIC_DIRECTORY$d" 
 
        if [ "x$SILENT" = "x" ] 
        then 
            echo "Checking for old tracking files in $NIC_DIRECTORY$d" 
        fi  
 
        #for j in `ls *-nic.* | awk 'BEGIN{FS="-nic"} {print $1}'` 
        #ls *-nic.* | while read j 
        find . -name "*-nic.*" -type f -print | awk 'BEGIN{FS="/"} {print $2}' | while read j 
        do 
            PASTFILETEMP=`echo $j | awk 'BEGIN{FS="-nic"} {print $1}'` 
            if [ ! -f "$d/$PASTFILETEMP" ] 
            then 
                if [ "x$SILENT" = "x" ] 
                then 
                    echo "remove $NIC_DIRECTORY$d/$PASTFILETEMP-nic.last.line" 
                fi 
                rm -f "$NIC_DIRECTORY$d/$PASTFILETEMP-nic.last.line" 
            fi 
        done  
    fi 
done 
DIRCOUNT=0 
for d in `echo "$DATA_DIRECTORY" | awk '{split($0, a, ":"); for (i in a) print a; }'` 
do 
    DIRCOUNT=`expr $DIRCOUNT + 1` 
    cd "$d" 
    mkdir -p "$NIC_DIRECTORY$d" 
 
    if [ "x$SILENT" = "x" ] 
    then 
        echo "**** Scanning directory $d..." 
    fi 
              
    for i in `echo "$FILESPEC" | awk '{split($0, a, ":"); for (k in a) print a[k]; }'` #Array has been added to $FILESPEC to support multiple filenames for multiple folders 
    #ls $FILESPEC | while read i 
    #find . -name "$FILESPEC" -type f -print | awk 'BEGIN{FS="/"} {print $2}' | while read i  
    do 
        if [ "x$SILENT" = "x" ] 
        then 
            echo "**** Processing $i..." 
        fi 
 
        # running date 
        #date +%s > "$NIC_DIRECTORY/running$ENVISION" 
        #Bug 112031 
        THEDATE=`perl -e 'print time(),"\n"'` 
        echo $THEDATE > "$NIC_DIRECTORY/running$ENVISION" 
        # running pid 
        echo $$ > "$NIC_DIRECTORY/running$ENVISION.pid" 
        # 
 
        if [ -f "$i" ] 
        then 
            TRANSFER_ERRORS=no 
            TIMESTAMP=`date +%Y%m%d%H%M%S` 
            LAST=1 
 
            if [ -f "$NIC_DIRECTORY$d/$i-nic.last.line" ] 
            then 
                LAST=`cat "$NIC_DIRECTORY$d/$i-nic.last.line" 2>/dev/null` 
            fi 
 
            WC=`wc -l "$i" | awk '{print $1}'` 
            WC=`expr $WC + 1` 
 
            if [ $WC -lt $LAST ] 
            then 
                LAST=1 
                                if [ "x$SILENT" = "x" ]  
                then 
                    echo "**** WARNING: file was shorter than expected.  Reading from the beginning." 
                        echo "**** Log file will be processed from line $LAST to $WC." 
                fi 
            fi 
         
            if [ $WC -eq $LAST ] 
            then 
                if [ -f "$NIC_DIRECTORY$d/$i-nic.last.time" ] 
                then                                        
                    if [ $NIC_DIRECTORY$d/$i-nic.last.time -ot $i ] 
                    then 
                                             LAST=1 
                         if [ "x$SILENT" = "x" ] 
                         then 
                                                echo "**** File $i timestamp has changed. Reading from the beginning" 
                                echo "**** Log file will be processed from line $LAST to $WC." 
                                             fi 
                         Nicsftp 
                    else 
                         #Fix bug 25079 
                         if [ "x$FLAG_REMOVE_FILE_AFTER_SEND" = "xyes" ]  
                         then 
                            if [ "x$SILENT" = "x" ] 
                            then 
                                echo "**** Removing Log File $i" 
                            fi 
                            rm -f "$i" 
                         fi 
                         # 
                    fi 
                else 
                    if [ "x$SILENT" = "x" ] 
                    then 
                        echo "**** No new data in $i." 
                                                TMPCOUNT=0 
                    fi 
                fi 
            else 
                #Fix bug ECE-165 
                if [ -f "$NIC_DIRECTORY$d/$i-nic.last.time" ] 
                then 
                    if [ $NIC_DIRECTORY$d/$i-nic.last.time -ot $i ] 
                    then 
                        if [ "x$FLAG_REMOVE_FILE_AFTER_SEND" = "xyes" ] 
                        then 
                            # Start from the beginning 
                            LAST=1 
                            if [ "x$SILENT" = "x" ] 
                            then 
                                echo "**** File $i timestamp has changed. Reading from the beginning" 
                                echo "**** Log file will be processed from line $LAST to $WC." 
                            fi 
                        fi 
                    fi 
                else 
                    LAST=1 
                fi 
                #End Fix 
                Nicsftp 
            fi 
 
            if [ "x$SILENT" = "x" ]  
            then 
                echo "**** Done processing file $d/$i ($i-nic.$TIMESTAMP-$DIRCOUNT.$UPLOAD_SPEC Sent $TMPCOUNT Lines)" 
            fi 
        fi 
    done 
 
    if [ "x$SILENT" = "x" ] 
    then 
        echo "**** Done processing directory $d" 
    fi 
done 
cd "$PWD" 
# clean up running files 
if [ "x$SILENT" = "x" ] 
then 
    echo "**** removing running files" 
fi 
 
if [ -f "$NIC_DIRECTORY/running$ENVISION" ] 
then 
    rm -f "$NIC_DIRECTORY/running$ENVISION" 
fi 
 
if [ -f "$NIC_DIRECTORY/running$ENVISION.pid" ] 
then 
    rm -f "$NIC_DIRECTORY/running$ENVISION.pid" 
fi 
 
if [ "x$SILENT" = "x" ] 
then 
    echo "**** Script Completed." 
fi

Pls use code tags as required by forum rules!

As it looks like, the script is distributed in a larger professional SW package, so I presume it should have been working when and as supplied.
What have you done so far to identify the error? What could you have done to induce the error?

I am not able to identify why this error is coming...???
Where the bug actually is???

Line 114? Count the lines in your script, or use cat -n .

Did the script run correctly when distributed? Did you edit it?

Line 114 is .from where Nicsftp() function starts that is Nicsftp().
Initialy when i run after distributing the script. There were approx 10-12 more errors in script befor Nicsftp() function. That was because of space between the lines. So i removed the spaces between two lines. Now i am getting only this error.

You didn't use a Microsoft / Windows editor like Notepad, did you?

i simply double click on the script in SUSE linux and modified it.

I had a suspicion and built a test case with Windows/DOS control chars in it; it's giving a very similar error msg:

$ cat -et test
#!/bin/bash$
# set -vx$
$
nic()^M$
{^M$
ls$
}^M$
$ ./test
./test: line 4: syntax error near unexpected token `$'\r''
'/test: line 4: `nic()

Check your script if it has e.g. ^M s in it.