Solaris 11 ksh93 if condition issue

Solaris 11 ksh93 if condition issue

Has anyone run into issues with Solaris 11 with ksh93 if condition where it intermittently return wrong return code?

We did not see this issue in Solaris 10 with ksh88

Any thoughts? Thanks!

Solaris version:

SunOS t52-ccc-28 5.11 11.2 sun4v sparc sun4v

ksh version:

  version         sh (AT&T Research) 93u 2011-02-08

example:

if grep "ora_smon_$oradb$" $ORATMP/$scrname.ps-fu.list.$$ 

would return 0 even though "ora_smon_$oradb" did not exist in the file

Please: give the full if - then fi block. Easier to say.

#Solaris 11 Bug checker...
  echo "grep 'ora_smon_$oradb$' $ORATMP/$scrname.ps-fu.list.$$ :"
  grep "ora_smon_$oradb$" $ORATMP/$scrname.ps-fu.list.$$
  echo "grep -q 'ora_smon_$oradb$' $ORATMP/$scrname.ps-fu.list.$$ :"
  grep -q "ora_smon_$oradb$" $ORATMP/$scrname.ps-fu.list.$$
  echo $?
  echo "cat $ORATMP/$scrname.ps-fu.list.$$ | grep 'ora_smon_$oradb$' :"
  cat $ORATMP/$scrname.ps-fu.list.$$ | grep "ora_smon_$oradb$"
  echo EOF.

 if grep "ora_smon_$oradb$" $ORATMP/$scrname.ps-fu.list.$$ #> /dev/null 2>&1
  then
    echo "`date +%D-%T`: $$: $locserv: $oradb: instance is up."
.
.
.
  else
    echo "`date +%D-%T`: $$: $locserv: $oradb: no instance, w/ audit file.  Priority 9."
  fi

RESULTS:

grep 'ora_smon_oemagent12$' /oracle/local/tmp/database_auditing.sh.ps-fu.list.12134 :
grep -q 'ora_smon_oemagent12$' /oracle/local/tmp/database_auditing.sh.ps-fu.list.12134 :
0
cat /oracle/local/tmp/database_auditing.sh.ps-fu.list.12134 | grep 'ora_smon_oemagent12$' :
EOF.
11/12/15-16:39:24: 12134: t52-ccc-14: oemagent12: instance is up.

Note:

there should never be a �ora_smon_oemagent� processes running, hence it should never be found in the �ps-fu.list� temp file.

grep will return 2 on errors.

I guess your .ps-fu.list.$$ file is faulty (not empty).
Check with a simple cat!