It has been awhile since I scripted. I was never good to begin with..
I am working on a script that would test an oracle DB connection.
testDB() {
[[ $(tnsping $tnsName | grep -c WRONG)==1 ]] && return 1
return 0
}
testDB
status="${?}"
echo "Status value= " $status
I am expecting a 0 value from my echo but somehow my status is showing 1 in my echo.
What am I doing wrong here?
EDIT2:
My original code was:
testDB() {
[[ $(tnsping $tnsName | grep -c OK) -eq 1 ]] && return 1
return 0
}
my $tnsName contains a correct value and the grep count would be 1, yet my functions returns 0.