![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| TAHI Test Suite 4.0.2 (Self-Test Test Suite branch) | iBot | Software Releases - RSS News | 0 | 07-10-2008 06:50 AM |
| TAHI Test Suite 3.0.15 (IPv6 Conformance Test Tool branch) | iBot | Software Releases - RSS News | 0 | 07-10-2008 06:50 AM |
| TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) | iBot | Software Releases - RSS News | 0 | 04-06-2008 12:20 PM |
| test and .test in same directory | vikashtulsiyan | SUN Solaris | 14 | 12-28-2007 02:25 AM |
| Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com | iBot | UNIX and Linux RSS News | 0 | 07-23-2007 10:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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
Code:
Nbr_BD_Link is :
0
we do a test
--------------------------------------------------------------------------------
La base MYDB contient
0 DB Link :
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
Code:
Nbr_BD_Link is : 0 we do a test Why ? Any idea ? Any help ? thank you. May be some caracter at the end of Nbr_BD_Link ? How to keep just zero ? |
|
||||
|
As you can see from the output and expect from your script, it has a leading newline and some spaces. Take out the newline just after the opening backtick and/or use a comparison operator which is slightly less picky about whitespace (I tend to recommend case over if test).
|
|
||||
|
Thank you.
How Take out the newline just after the opening backtick ? iTRIED FOR CASE / :man case Manual entry for case not found or not installed. [:man select Manual entry for select not found or not installed. [:man CASE Manual entry for CASE not found or not installed. Last edited by big123456; 08-01-2008 at 09:17 AM.. |
|
||||
|
case is a shell built-in, like if and while; it's documented in the sh manual page. If you have bash (or, I suppose, any of a number of other modern shells), try help case
You have a newline before "sqlplus"; by "take out the newline" I meant, move the sqlplus command to the same line as the opening backtick. 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 '${Nbr_BD_Link}'"
echo "we do a test"
case ${Nbr_BD_Link} in
*[1-9]*) echo "${T80}\nLa base ${DB_Name} contient ${Nbr_BD_Link} DB Link :" ;;
esac
Last edited by era; 08-01-2008 at 09:35 AM.. Reason: Also suggest "help case" |
|
||||
|
Thank you.
|
| Sponsored Links | ||
|
|