The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




Thread: test if
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-01-2008
big123456 big123456 is offline
Registered User
  
 

Join Date: May 2005
Posts: 200
test if

Hi,
I have this script :

Code:
Nbr_BD_Link=`
sqlplus -S sysadm/${PSWD}@${DB_Name} << EOF
        set head off feedback off  ;
        select count(*) from dba_db_links ;
        exit ;
EOF `
echo "Nbr_BD_Link is : "
echo ${Nbr_BD_Link}
echo "we do a test"
if [ "${Nbr_BD_Link}" != "0" ] ; then
echo "${T80}\nLa base ${DB_Name} contient ${Nbr_BD_Link} DB Link :"
fi

The result of execution is

Code:
Nbr_BD_Link is :
0
we do a test
--------------------------------------------------------------------------------
La base MYDB contient
         0 DB Link :

As you can see, the conditional echo "${T80}\nLa base ${DB_Name} contient ${Nbr_BD_Link} DB Link :" is executed even if Nbr_Bd_Link is zero.
Now I force Nbr_BD_Link to be zero :

Code:
Nbr_BD_Link=0
Nbr_BD_Link=`
sqlplus -S sysadm/${PSWD}@${DB_Name} << EOF
        set head off feedback off  ;
        select count(*) from dba_db_links ;
        exit ;
EOF `
echo "Nbr_BD_Link is : "
echo ${Nbr_BD_Link}
echo "we do a test"
Nbr_BD_Link=0
if [ "${Nbr_BD_Link}" != "0" ] ; then
echo "${T80}\nLa base ${DB_Name} contient ${Nbr_BD_Link} DB Link :"
fi

The result would be

Code:
Nbr_BD_Link is :
0
we do a test

The condition is respected and the conditional echo "${T80}\nLa base ${DB_Name} contient ${Nbr_BD_Link} DB Link :" is not executed.
Why ? Any idea ?
Any help ? thank you.
May be some caracter at the end of Nbr_BD_Link ? How to keep just zero ?