finding difficult to check a condition


 
Thread Tools Search this Thread
Operating Systems Solaris finding difficult to check a condition
# 1  
Old 11-07-2008
finding difficult to check a condition

Hi all,
I have a condition
if(($x>0))
then echo "ok"

x=`sqlplus -s dmiapp/dmiappl_04@dmid << EOF
SELECT count(*) FROM $TABLE_NAME
exit
EOF`

Now the problem occurs when the above code returns an error message (RETURNs a string )as database is down.

I have created the script for checking the database is down or up.
Please give some clue.

Regards
Megh
# 2  
Old 11-07-2008
Yes,
try this:

Code:
x="$(sqlplus -s << EOF
user/pass@service
set pages 0 feed off
SELECT ltrim(count(*)) FROM $TABLE_NAME;
EOF
)"

case $x in 
  "" | *[!0-9]* ) printf "Invalid number: %s\n" "$x";; 
              * ) (( $x > 0 )) && printf "OK\n" || printf "KO\n";; 
esac

P.S. I wouldn't post database username and password on a public forum Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check two condition in while loop

Hi, I Have to check two condition in while loop every 2 minutes. while loop is accompanied with number of times it will check.Please help in putting the two condition in while loop as appropriate. z= input value, A=1 while do 1.check the file output,if the file output is N then keep on... (2 Replies)
Discussion started by: netdbaind
2 Replies

2. Shell Programming and Scripting

If condition to check null variable

Guys, Please help me on the below sample.cfg var=NULL sample.sh #!/bin/sh . /sample.cfg if ;then 1 st command here else 2 nd command here fi (3 Replies)
Discussion started by: AraR87
3 Replies

3. UNIX for Dummies Questions & Answers

If condition to check one file newer than the other

Dear All, I'm new to unix scripting. I'm trying to write an utility script which has to check if one file is newer than another one. $3 $4 $5 $6 are files .txt. Help me please. for i in $3 $4 $5 $6 do if then echo "$1 is newer than $i" else echo "$i is newer than $1" fi (9 Replies)
Discussion started by: Manueldo
9 Replies

4. UNIX for Dummies Questions & Answers

Condition check using awk

Hi, I have a file in the following format "SYLVESTER,WILLARD G"|"S00633600"|"221052958A"|"H2256"|"015"|""|"00000042BASJ"|"665303"|"N"|"20100211"|"380.4"|""|""|""|"5400"|"20110218"|""|"20110218"|"FEESC"|"D"|"F"|"P" "PURINGTON-KELLEY,C"|"S00808783"|"029424717A"|"H2256"|"024"|"MEMBER JOINED... (3 Replies)
Discussion started by: nua7
3 Replies

5. Shell Programming and Scripting

if condition to check the hostname (unix)

I want to know the if condition in checking the hostname in unix and then running a cron job (all in a single line) Thanks (2 Replies)
Discussion started by: prash358
2 Replies

6. Shell Programming and Scripting

Help with Awk finding and replacing a field based on a condition

Hi everybody, I'm trying to replace the $98 field with "T" if the last field (108th) is T I've tried awk 'BEGIN{OFS=FS="|"} {if ($108=="T")sub($98,"T"); print}' test.txt but that doesn't do anything also tried awk 'BEGIN{OFS=FS="|"}{ /*T.$/ sub($98,"T")} { print}' test.txt but... (2 Replies)
Discussion started by: jghi123
2 Replies

7. Shell Programming and Scripting

How to check a list of 4-5 strings in IF condition?

Hi Unix Champs, I am a newbe to UNIX. I need to create a condition where I want to check the value of a variable with 5 different strings, if matched then exit 1. For ex: if ] then echo "yes, condition satisfied...." else echo "no, condition not satisfied..." fi ... (9 Replies)
Discussion started by: ustechie
9 Replies

8. Shell Programming and Scripting

WHILE LOOP CONDITION CHECK

Hello I want to compare values of two variables as CHECK condition in a while loop. eg: var1=0 var2=10 while do echo " $var1 " var1=`expr $var1 + 1` done However this is giving error.How to do it in a proper manner? Thanks. (3 Replies)
Discussion started by: dashing201
3 Replies

9. Solaris

Finding difficult in installing gcc-3.4.6 complier on Solaris 10.

Hi All, Can anyone help me in installing gcc-3.4.6 complier on Solaris 10. 1. I have downloaded the gcc-3.4.6.tar.gz from one of the free share 2. While downloading its is seen that it is renamed to gcc-3.4.6.tar.tar 3. On solaris machine I renamed it gcc-3.4.6.tar.gz from gcc-3.4.6.tar.tar... (4 Replies)
Discussion started by: susainaj
4 Replies
Login or Register to Ask a Question