Visit Our UNIX and Linux User Community

Solaris 11 ksh93 if condition issue

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solaris 11 ksh93 if condition issue
# 1  
Old 02-16-2016
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


if grep "ora_smon_$oradb$" $ORATMP/$$$ 

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

Last edited by Scrutinizer; 02-16-2016 at 12:39 PM.. Reason: code tags
# 2  
Old 02-16-2016
Please: give the full if - then fi block. Easier to say.
# 3  
Old 02-16-2016
#Solaris 11 Bug checker...
  echo "grep 'ora_smon_$oradb$' $ORATMP/$$$ :"
  grep "ora_smon_$oradb$" $ORATMP/$$$
  echo "grep -q 'ora_smon_$oradb$' $ORATMP/$$$ :"
  grep -q "ora_smon_$oradb$" $ORATMP/$$$
  echo $?
  echo "cat $ORATMP/$$$ | grep 'ora_smon_$oradb$' :"
  cat $ORATMP/$$$ | grep "ora_smon_$oradb$"
  echo EOF.

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


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


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

Last edited by Scrutinizer; 02-16-2016 at 12:40 PM.. Reason: code tags
# 4  
Old 02-16-2016
grep will return 2 on errors.

Last edited by achenle; 02-16-2016 at 02:57 PM..
# 5  
Old 02-16-2016
I guess your .ps-fu.list.$$ file is faulty (not empty).
Check with a simple cat!

Previous Thread | Next Thread
Test Your Knowledge in Computers #562
Difficulty: Easy
Normally, the control flow of a program is sequential: each statement is executed right-to-left the next statement before the current statement.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Ksh93 on Linux compatible with ksh93 on AIX

Hi Experts, I have several shell scripts that have been developed on a Linux box for korn ksh93. If we want to run this software on an AIX 6.1 box that runs ksh88 by default can we just change the she-bang line to reference /bin/ksh93 which ships with AIX as its "enhanced shell" to ensure... (6 Replies)
Discussion started by: Keith Turley
6 Replies

2. Shell Programming and Scripting

Issue with IF condition

Getting syntax error when the condition after -o returns more than one file if then echo "Found" fi output: =>ls -l total 5 -rw-rw-r-- 1 wes wes 0 Jun 25 04:51 a.done -rw-rw-r-- 1 wes wes 0 Jun 25 04:51 -rw-rw-r-- 1 wes wes ... (13 Replies)
Discussion started by: anijan
13 Replies

3. Shell Programming and Scripting

If Condition Issue in UNIX

Hi I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed) If Each File size EXCEEDS parameter passed SIZE then we manipulate the file. Somehow the IF condition do not work ?? (is this Variable decalration issue ??) ... (9 Replies)
Discussion started by: Pete.kriya
9 Replies

4. Shell Programming and Scripting

Condition checking issue while if

hi, i am using a simple condition end_ct=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID << EOF select description from bravo_statistics where trunc(time_stamp)=trunc(sysdate)-1 and description='END CAT'; EOF` echo $end_ct; echo... (30 Replies)
Discussion started by: lovelysethii
30 Replies

5. Shell Programming and Scripting

if condition issue

Hi, I have prepared the below shell script for one of the requirement which accesses Informatica application and performs certain functions. But for some reason, if condition fails and scripts stops abruptly with the below error. Please let me know the where the problem is #!/bin/ksh ... (2 Replies)
Discussion started by: svajhala
2 Replies

6. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

7. Shell Programming and Scripting

if condition issue

Hi, Unix Gurus, I got some issue with my script. #!/usr/bin/ksh while read newstatus do if ; then echo "It is finished " else echo "Not Finished" fi done <checkresult.txt basically, I want to read one file (the file only contains one word, but it dynamically changed),... (2 Replies)
Discussion started by: ken002
2 Replies

8. UNIX for Dummies Questions & Answers

If condition issue

Hello, I am using the following code #!/bin/sh chris='rerun' chris2=$1 echo "chris=$chris" echo "chris2=$chris2" if then echo "RERUN" else echo "NOT RERUN" fi (6 Replies)
Discussion started by: chriss_58
6 Replies

9. Shell Programming and Scripting

An issue with condition statement in shell script

Hello forum members. please go through the below mentioned issue and let me know the right solution. I have to write a script which runs another script .the executable script take input iam writing the the script below . Sample Code:Begins #! /bin/ksh echo " enter... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

10. Shell Programming and Scripting

ksh93 deprecation...

Any means of running ksh93 in a ksh88-mode? Might sound odd, but I want/need to restrict U/Win-developed scripts to correspond to the ksh88 version on my Solaris environment(s). Thanks. (2 Replies)
Discussion started by: curleb
2 Replies

Featured Tech Videos