Problem in shell script

 
HOSTNAME=`uname -n`
/usr/sbin/clinfo
CLUSTERACTIVE=$?
# First check whether the Cluster itself is active
if [ $CLUSTERACTIVE != "0" ]
  then
        echo Cluster is NOT ACTIVE - EXITING
          exit 1
  fi
# Now check whether we are on the active Cluster Node for this Resource Group
CLUSTERSTATE=`/usr/cluster/bin/scha_resource_get -R ora-db03-lh-rs -O RESOURCE_STATE_NODE $HOSTNAME`
if [ $CLUSTERSTATE != "ONLINE" ]
  then
        echo "Cluster is NOT ON ACTIVE CLUSTERNODE for this resource group - EXITING"
          exit 1
  fi
echo "Cluster status check OK"
### Cluster check done
# check whether correct User executes this Script
USERNAME=$LOGNAME
if [ ! $USERNAME = "root" ]
  then
        echo "WRONG USERNAME, must be User ROOT"
        exit 1
  fi
echo "User check OK"
### User check done
# Get command Line Parameters
INSTANCE=$1
USR=$2
# Now check whether required Parameter has been given on command Line
if [ ! $# = "2" ]
  then
        echo
        echo "Wrong number of Parameters or no Parameter have been given. USAGE: arc_aging.sh FIN/DIS ocafin1/oracle"
        echo
        exit 1
  else
        echo "Parameter count check OK"
  fi
# Now check whether valid Parameters have been given
if [ "$INSTANCE" = "FIN" -o "$INSTANCE" = "DIS" ]
  then
        echo "Parameter validation check OK"
  else
        echo "Parameter must be FIN or DIS !!"
        exit 1
  fi
if [ "$USR" = "ocafin1" -o "$USR" = "oracle" ]
  then
        echo "Parameter validation check OK"
  else
        echo "Parameter must be oracle or ocafin1 !!"
        exit 1
  fi
### Parameter check done
# Build local Environment Variables
INSTANCE_REDO=$1_REDO2
## Set the archive Directory
ARCH1="/global/$INSTANCE_REDO/archlogs"
ARCH2="/global/ORA_BACKUP/archlogs/$INSTANCE"
ARCH3="/global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
ARCH4="/global/LOG_REPLICATION/$INSTANCE"
# Delete Archive logs on /global/LOG_REPLICATION/$INSTANCE volume when not accessed since 10 days
# These are the archive logs which where replicated to Euromoda/TIU via SNDR
echo "SNDR: Deleting Archive Logs on /global/LOG_REPLICATION/$INSTANCE older than 10 days ...."
date '+Start: %H:%M:%S'
echo "The following files are going to be deleted:"
su $USR -c "find $ARCH4 -type f -atime +10 -exec ls {} \;"
su $USR -c "find $ARCH4 -type f -atime +10 -exec rm {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Delete Archive logs on /global/ORA_BACKUP volume when not accessed since 15 days
echo "Cleaning up Archive Logs on /global/ORA_BACKUP/archlogs/$INSTANCE/compressed older than 15 days ...."
date '+Start: %H:%M:%S'
echo "The following files are going to be deleted:"
su $USR -c "find $ARCH3 -type f -atime +10 -exec ls {} \;"
su $USR -c "find $ARCH3 -type f -atime +10 -exec rm {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
 
# Compress Archive logs on /global/ORA_BACKUP volume when not accessed since 2 days
echo "Compressing Archive Logs on /global/ORA_BACKUP/archlogs/$INSTANCE older than 2 days ...."
date '+Start: %H:%M:%S'
su $USR -c "find $ARCH2 -name compressed -prune -o -type f -atime +2 -exec ls {} \;"
su $USR -c "find $ARCH2 -name compressed -prune -o -type f -atime +2 -exec compress {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Move compressed files to subfolder
echo "Moving compressed files to subfolder ...."
date '+Start: %H:%M:%S'
su $USR -c "mv /global/ORA_BACKUP/archlogs/$INSTANCE/*.Z /global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
su $USR -c "mv /global/ORA_BACKUP/archlogs/$INSTANCE/*.gz /global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
echo Return code: $?
date '+End: %H:%M:%S'
# Move Archive logs from /global/(FIN/DIS)_REDO2/archlogs to the /global/ORA_BACKUP volume when not accessed since 1 day
echo "Moving Archive Logs to /global/ORA_BACKUP/archlogs/$INSTANCE older than 1 day ...."
date '+Start: %H:%M:%S'
su $USR -c "find $ARCH1 -name compressed -prune -o -type f -atime 1 -exec ls {} \;"
su $USR -c "find $ARCH1 -name compressed -prune -o -type f -atime 1 -exec mv {} /global/ORA_BACKUP/archlogs/$INSTANCE/ \;"
echo Return code: $?
date '+End: %H:%M:%S'
echo "Current Disc usage ...."
df -k|grep ORA
df -k|grep $INSTANCE_REDO
 
/root/scripts>./ARC-PURGE.sh ESPOS espos 2>&1 mailx -s "ESPOS Archivelog Purge" babu.knb@gmail.com
User check OK
Wrong number of Parameters or no Parameter have been given. USAGE: arc_purge.sh ESPOS/FPRINT espos/fprint

I got below error message. Please advice me what was the problem?

try if [ $# != 2 ] instead of if [ ! $# = 2 ]

Bash has a built-in operator -ne for integer comparison. I would re-write the code for checking number of argument as:
if [ $# -ne 2 ]; then