Reputation: 47
I have below conditions . IF all conditions are meet then it passes. If it fails then need to know which condition makes it to fail ?
if [[ -z “$pas” ]] && [[ $dd_check_pass == “pass” ]] && [[ $asmresultcheck == “pass” ]];
then
zzz=Passed;
else
zzz=Failed;
aaa=”Due to unknown process running”
fi
Upvotes: 2
Views: 32
Reputation: 47
pass=""
dd_check_pass="pass"
asmresultcheck="pass"
var=pass
case $var in
pass)
if [[ -z $pasrep ]]
then
echo "\n"
echo "users condition Passed"
else
echo "\n"
echo "users condition failed"
fi
;&
dd_check_pass)
if [[ $dd_check_pass == "pass" ]]
then
echo "\n"
echo "cluster check passed"
else
echo "\n"
echo "cluster check failed"
fi
;&
asmresultcheckin)
if [[ $asmresultcheck == "pass" ]]
then
echo "\n"
echo "asm check passed"
else
echo "\n"
echo "asm check failed"
fi
;&
esac
echo "\n"
echo "Check the above result. If all are passed then proceed with duedeligence or else don't proceed. Do you wish to proceed (y/n)?"
read ans
if [ $ans == y ]
then
echo "\n"
echo "passed"
else
echo "\n"
echo "failed"
fi
Upvotes: 0
Reputation: 247210
If you need to know which condition failed, then you need to act on each one individually:
if [[ -n "$pas" ]]; then
aaa="pas variable is not empty"
zzz=Failed
elif [[ $dd_check_pass != "pass" ]]; then
aaa="dd_check_pass variable is not pass"
zzz=Failed
elif [[ $asmresultcheck != "pass" ]]; then
aaa="asmresultcheck variable is not pass"
zzz=Failed
else
zzz=Passed
fi
Upvotes: 1