The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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 3.0.15 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 07-10-2008 06:50 AM
PING - Unknown host 127.0.0.1, Unknown host localhost - Solaris 10 Przemek SUN Solaris 4 05-26-2008 12:11 AM
TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 04-06-2008 12:20 PM
:0: unknown test operator ibroxy Shell Programming and Scripting 2 08-10-2007 04:59 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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-01-2008
big123456 big123456 is offline
Registered User
  
 

Join Date: May 2005
Posts: 200
unknown test operator

Hi,
I have the following shell script :

Nbr_BD_Link=0
Nbr_BD_Link=`
sqlplus sysadm/${PSWD}@${DB_Name} << EOF | tail -4 | head -1 2>/dev/null
set head off feedback off ;
select count(*) from dba_db_links ;
exit ;
EOF `
echo ${Nbr_BD_Link}
if [ ${Nbr_BD_Link} != "0" ] ; then


execution fail on line if [ ${Nbr_BD_Link} != "0" ] ; then

Like this :
Enter user-name: SP2-0306: Invalid option.
Check_DB_Link_BR.sh[71]: user-name:: unknown test operator

Any idea ? Any help.
Many thanks.
  #2 (permalink)  
Old 08-01-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Try
Code:
if [[ "${Nbr_BD_Link}" != "0" ]] ; then
Are you sure that the value of this variable will ever be 0 or do you mean if the value is null in terms of empty? Because then you might want to test with -z or if value is "".

This might be interessting for you:
Bourne/Korn Shell Coding Conventions at OpenSolaris.org
  #3 (permalink)  
Old 08-01-2008
big123456 big123456 is offline
Registered User
  
 

Join Date: May 2005
Posts: 200
Thank you. Yes primarily it was that , I mean
Code:
[ ${Nbr_BD_Link} != "0" ]
Instead of
Code:
[ "${Nbr_BD_Link}" != "0" ]
But now I can see that Nbr_BD_Link has not a numeric value , it is
Nbr_BD_Link=SQL>SQL

Any idea ?
Thank for help.
  #4 (permalink)  
Old 08-01-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
What does this echo results ? If you expect some numeric value why are you getting string as result. Does it mean you statement not functioning correctly ?

- nilesh
  #5 (permalink)  
Old 08-01-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
From a separate thread by the same author, I concede that adding the quotes basically solved the problem
Sponsored Links
Closed Thread

Bookmarks

« ssh key | test if »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0