logical if condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting logical if condition
# 1  
Old 06-27-2007
logical if condition

hi
i have the following scenario
#!/bin/sh

a=21.0
b=33.0
c=16.0
cmd=20
cmd1=30

if [ [$a -gt $cmd ] && [$b -gt $cmd1] ]
then
echo "problem....."
exit 1
else
echo "ok"
exit 0
fi

the issue here is the above condition is never TRUE coz a>cmd && b >cmd1
Any ideas ?
# 2  
Old 06-27-2007
Try:
#!/bin/sh

Code:
a=21.0
b=33.0
c=16.0
cmd=20
cmd1=30

if [ $a -gt $cmd -a $b -gt $cmd1 ] 
then 
   echo "problem....."
   exit 1 
else
   echo "ok"
   exit 0
fi

# 3  
Old 06-27-2007
The following works:
Code:
#!/bin/ksh

typeset -i a=21.0
typeset -i b=33.0
typeset -i c=16.0
typeset -i cmd=20
typeset -i cmd1=30

if [ $a -gt $cmd -a $b -gt $cmd1 ]
then
  echo "problem....."
  exit 1
else
  echo "ok"
  exit 0
fi

# 4  
Old 06-27-2007
Thanks for that ....
#/bin/sh
USER=me

Would any of ye know the equivalent of the following command :

This works fine on solaris :

/bin/ps -o pcpu,args -u$USER


but not working on solaris

Any ideas ??????
# 5  
Old 06-27-2007
For a new question, create a new thead.

Works fine on my AIX box.
On which system do you have a problem with this ps command ?
# 6  
Old 06-27-2007
HPUX is the machine the problem is
# 7  
Old 06-27-2007
Have you read the man pages for HP-UX ps ?
I found a HPUX ps man page on the net (HPUX ps). Seems thet the -o option doesn't exist.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

2. Shell Programming and Scripting

trying to use logical or and i must be missing something

greetings, i am trying to force the user to ensure that $CPUS equals 12 or 24. it cannot be any other value including null. after the expr statement $AMT needs to equal 1 or 2. how i read the line in question is "if $CPUS is zero/null or not equal to 12 or not equal to 24" then issue the message,... (5 Replies)
Discussion started by: crimso
5 Replies

3. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

4. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

5. AIX

Logical Partitions?

I'm trying to find out how many logical partitions our AIX box has. I'm running the command: topas -C and nothing is showing up. Is it safe to say that there is only one LPAR, which is what AIX is installed on? Move to AIX - jim mc (2 Replies)
Discussion started by: NycUnxer
2 Replies

6. Shell Programming and Scripting

Logical error

I have this script to uvscan-update. Seems like that i am getting logical error at the end of the script. It is updating the script and also giving the error message to update it manually. I have deleted the DAT files to see if it will create new and it does. Below is the error and the script: ... (1 Reply)
Discussion started by: mk07md
1 Replies

7. Shell Programming and Scripting

How to do logical AND and logical OR with grep

Hi can someone please help me on this. I need to perform this code: Grep any lines that meets the following criteria (A AND B) OR (A AND C) I tried this code, but it didn't work Grep-I "A &&B" | "A&&C" *.* $ thanks in advance (12 Replies)
Discussion started by: Needhelp2
12 Replies

8. Shell Programming and Scripting

logical OR in sed

frnds.. can i perform an OR operation in sed syntax ? if yes.. how? I need to search for some 2-3 mail addresses in multiple files and delete all those... and instead of them.. I need to insert a new mail id...( these are also other emails in that list .. which sud not be affected ) is... (8 Replies)
Discussion started by: clx
8 Replies
Login or Register to Ask a Question