never ending loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting never ending loop
# 15  
Old 10-05-2006
vgersh,
i now understand what you meant. your code is working like this. output of type -x is as follows
Code:
+ i=0
+ [ 0 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_AlltelWebOrders');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 1 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_Alltel24hrs');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 2 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_Alltel4hrs');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 3 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_AlltelImmediate');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 4 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_AlltelBBHC');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 5 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_AlltelBBLM');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 6 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFA_AlltelWebOrders');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 7 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WfProcMgr');
X=       0
+ [ 0 -gt 0 ]
+ (( i=i+1 ))
+ [ 8 -lt 9 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'eProdCfgObjMgr_enu');
X=       1
+ [ 1 -gt 0 ]
+ + whence FusionHC.ksh
thisFILE=/siebel/sble01/siebfile/batch/FusionHealthCheck/FusionHC.ksh
+ FUSER=/usr/sbin/fuser
+ echo running MASTER...
running MASTER...
+ nawk {print NF}
+ /usr/sbin/fuser /siebel/sble01/siebfile/batch/FusionHealthCheck/FusionHC.ksh
+ 2> /dev/null
+ typeset -i numProc=4
+ [[ 4 -gt 3 ]]
+ echo hi
hi
+ exit 1

i want the code in bold to be executed after the typeset count exceeds 3 and also reset the typset -i numprocc count to 0 once it starts executing the code in bold becoz this script executes every 15 minutes.

Code:
while [ $i -lt ${#wfcomp[*]} ]
do
X=`sqlplus -s batch_user/batch_user@$FUSION_SID << EOF5
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = '${wfcomp[$i]}');
EOF5`
if [ $X -gt 0 ]
then
  thisFILE="$(whence ${0})"

FUSER='/usr/sbin/fuser'

echo 'running MASTER...'

typeset -i numProc=$(${FUSER} ${thisFILE} 2>/dev/null | nawk '{print NF}')

if [[ "${numProc}" -gt 3 ]]; then
echo hi
  exit 1
fi

echo '   calling MASTER'
${thisFILE}

$FusionHC_DIR/WFStart.ksh

fi
((i=i+1))
done

ERRORS=`echo $RETURN | grep ERROR`
if [ "$ERRORS" != "" ]
then
  print "ERROR: `date '+%Y/%m/%d %H:%M:%S'` " >> $LOGFILE
  print "$RETURN" >> $LOGFILE
  exit 50
fi

rm $output

#-----Check Results and send error to ITO---
print "INFO: `date '+%Y/%m/%d %H:%M:%S'` Checking ITO." >> $LOGFILE
$FusionHC_DIR/ITOGen.ksh
exit

# 16  
Old 10-05-2006
Quote:
i want the code in bold to be executed after the typeset count exceeds 3 and also reset the typset -i numprocc count to 0 once it starts executing the code in bold becoz this script executes every 15 minutes.
it seems like the loop does does exit once the numProc reaches '4'.
do you understand how 'numProc' gets derived? It figures out how many instances of THIS script are running already. Once this number reache 4 - the script exist on the 4-th invokation.

There's no need to set the numProc to '0'.

Based on your 'set -x' output - it looks like the script does what's supposed to do.
# 17  
Old 10-05-2006
once it reaches the 4th instance, i dont want to do an exit 1. instead i want the code in bold that i sent to be executed. how do i do that, thanks
# 18  
Old 10-05-2006
Quote:
Originally Posted by ragha81
once it reaches the 4th instance, i dont want to do an exit 1. instead i want the code in bold that i sent to be executed. how do i do that, thanks
this is NOT what you wanted to do originally........
Code:
while [ $i -lt ${#wfcomp[*]} ]
do
X=`sqlplus -s batch_user/batch_user@$FUSION_SID << EOF5
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = '${wfcomp[$i]}');
EOF5`
if [ $X -gt 0 ]
then
  thisFILE="$(whence ${0})"

FUSER='/usr/sbin/fuser'

echo 'running MASTER...'

typeset -i numProc=$(${FUSER} ${thisFILE} 2>/dev/null | nawk '{print NF}')

#echo '   calling MASTER'
#${thisFILE}

$FusionHC_DIR/WFStart.ksh

fi
((i=i+1))
done

if [[ "${numProc}" -gt 3 ]]; then
   echo "Exceeded 3 instances: [${numProc}]"
   ERRORS=`echo $RETURN | grep ERROR`
   if [ "$ERRORS" != "" ]; then
      print "ERROR: `date '+%Y/%m/%d %H:%M:%S'` " >> $LOGFILE
      print "$RETURN" >> $LOGFILE
      exit 50
   fi

   rm $output

   #-----Check Results and send error to ITO---
   print "INFO: `date '+%Y/%m/%d %H:%M:%S'` Checking ITO." >> $LOGFILE
   $FusionHC_DIR/ITOGen.ksh
   exit
fi


Last edited by vgersh99; 10-05-2006 at 01:18 PM..
# 19  
Old 10-05-2006
thanks a lot..vgersh,

i was able to get it,,
# 20  
Old 10-05-2006
Quote:
Originally Posted by ragha81
thanks a lot..vgersh,

i was able to get it,,
you're welcome.
would be interesting to see the final working version.
# 21  
Old 10-06-2006
hi vgersh, sry for the late reply. was sleeping happilu. this is the final code that i used

Code:
##########################################################################################
i=0
while [ $i -lt ${#wfcomp[*]} ]
do
X=`sqlplus -s batch_user/batch_user@$FUSION_SID << EOF5
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = '${wfcomp[$i]}');
EOF5`
if [ $X -gt 0 ]
then

thisFILE="$(whence ${0})"

FUSER='/usr/sbin/fuser'

echo 'running MASTER...'

typeset -i numProc=$(${FUSER} ${thisFILE} 2>/dev/null | nawk '{print NF}')

#echo '   calling MASTER'
#${thisFILE}

$FusionHC_DIR/WFStart.ksh

fi

##########################################################################################
if [[ "${numProc}" -gt 3 ]]; then
  

ERRORS=`echo $RETURN | grep ERROR`
if [ "$ERRORS" != "" ]
then
  print "ERROR: `date '+%Y/%m/%d %H:%M:%S'` " >> $LOGFILE
  print "$RETURN" >> $LOGFILE
  exit 50
fi

rm $output

#-----Check Results and send error to ITO---
print "INFO: `date '+%Y/%m/%d %H:%M:%S'` Checking ITO." >> $LOGFILE
$FusionHC_DIR/ITOGen.ksh
fi
((i=i+1))
done
exit

However I have a problem again. this is the set -x output i have. it gives numproc value as 25, when it should be just 4. what could be the reason.

Code:
Commit point reached - logical record count 38
+ i=0
+ [ 0 -lt 2 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFM_AlltelWebOrders');
X=       0
+ [ 0 -gt 0 ]
+ [[  -gt 3 ]]
+ (( i=i+1 ))
+ [ 1 -lt 2 ]
+ + sqlplus -s batch_user/batch_user@ACSBLEST
+ 0<<
  set heading off
  SET FEEDBACK OFF
  SET PAGESIZE 0
  SET LINESIZE 900
  select count(*) from FusionHC_Result where (status not in ('Online', 'Running') and CC_ALIAS = 'WFA_AlltelWebOrders');
X=       0
+ [ 0 -gt 0 ]
+ [[  -gt 3 ]]
+ (( i=i+1 ))
+ [ 2 -lt 2 ]
+ exit
+ [[ 25 -gt 3 ]]
+ + grep ERROR
+ echo
ERRORS=
+ [  !=  ]
+ rm /siebel/sble01/siebfile/batch/FusionHealthCheck/FusionHC.out.
+ date +%Y/%m/%d %H:%M:%S
+ print INFO: 2006/10/06 16:51:25 Checking ITO.
+ 1>> /siebel/sble01/siebfile/batch/FusionHealthCheck/FusionHC.log
+ /siebel/sble01/siebfile/batch/FusionHealthCheck/ITOGen.ksh
The VPO Message Command is not configured on this system.
Contact your VPO Administrator to configure it. (OpC30-913)
+ (( i=i+1 ))
+ [ 2 -lt 2 ]
+ exit

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If loop not ending

Hi, The first if loop in the script not ending and going to infinite loop. #!/usr/bin/ksh set -vx lc=1 st_date=$(date "+%Y%m%d") LOGFILE=/home/infa_shared/OM_ftp_transfer.log.$st_date file="/home/infa_shared/OM_WF.log.$st_date" while ]; do if ] then sleep 15 let lc=lc+1 print... (4 Replies)
Discussion started by: nag_sathi
4 Replies

2. UNIX for Advanced & Expert Users

Ending Spam and Etc.

This is a very general question but the idea popped into my head several years ago and wanted the opinions of all the master jedi's of this forum. I had a client that no matter what was done to control there spam(spam assassin,anti-virus(email scanning) and etc) sooner or later something would slip... (2 Replies)
Discussion started by: metallica1973
2 Replies

3. Shell Programming and Scripting

Remove ending text

Hello, I am working with a list that contains a large number of files listed by their absolute path. I am trying to determine a way to delete the file name at the end of each line, therefore leaving just the directory path. For example, I'd like to go from: /home/something/file... (2 Replies)
Discussion started by: omnivir
2 Replies

4. Shell Programming and Scripting

Nested for loop not ending

Hi All, Need help on below script for g in `cat /home/sid.txt` do for h in `cat /home/dev.txt` do symmaskdb -sid $g -dev $h list assign |grep FA |head -1|awk '{print $2}' > tt1.txt done done cat /home/sid.txt ************** 123 235 456 (5 Replies)
Discussion started by: ranjancom2000
5 Replies

5. SCO

File name ending with @

Hi Current SCO Unix 5.05 I see that there are filenames with @ at the end of file name for example in the /usr/lib there is file lpadmin@ what does the @ represent when it is at the end of the file name Thanks (4 Replies)
Discussion started by: atish0
4 Replies

6. Shell Programming and Scripting

Ending a script

Hi all, I am trying to end a Menu script. Can people suggest various methods please? At the moment I am doing: quit=n while do ...Code Code Code... read userinput case $userinput in q|Q) quit=y;; esac done But this doesn't seem to work every time, occasionally it will work,... (6 Replies)
Discussion started by: mikejreading
6 Replies

7. Programming

executables ending with *

Hi All, I m very new to unix. I have a basic doubt .. In unix I m seeing that there is a * at the end of by executable name (exe1*).. Wht is the significance of that Thanks a lot in advance (2 Replies)
Discussion started by: binums
2 Replies

8. UNIX for Dummies Questions & Answers

File- Ending

Hi folks! I'm new in this forum and in the UNIX-world too!! I've got a real problem: I have to read out datas like name and e-mail-adress from a Windows- Server from the active directory and put this information into a file. This file should be moved (or copied) on a Unix- Server... But I... (3 Replies)
Discussion started by: spikylina
3 Replies

9. UNIX for Dummies Questions & Answers

Ending Mail

hello, I a problem. I would like write script in True64 Unix.see below. last testerkl | head > mailfile.asc wolteru < mailfile.asc With the "last" command I get a list when testerkl logged on. And I would like to send this to a user. But how can I write in a "ctrl.-d" and "ctrl.-c" that... (2 Replies)
Discussion started by: Peterh
2 Replies
Login or Register to Ask a Question