|
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 ?
|