The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comparing 2 files using nested for loop vadharah Shell Programming and Scripting 0 03-01-2008 04:32 AM
Nested loop not running using cronjob bihani4u Shell Programming and Scripting 9 09-26-2007 11:19 AM
Variable in While Loop Nested If geass Shell Programming and Scripting 6 03-26-2007 06:09 PM
Nested Loop to Echo Multiple Arrays yongho Shell Programming and Scripting 1 07-12-2005 11:35 AM
Nested while read line loop Rakker Shell Programming and Scripting 7 06-24-2005 07:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-14-2005
chinog chinog is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 4
nested loop

I have two do loops. When I break of the inner loop it doesn't go back to the outer loop but exit the program.
  #2 (permalink)  
Old 04-14-2005
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Please post your code. Also, post which shell and OS you are using.
  #3 (permalink)  
Old 04-14-2005
chinog chinog is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 4
Korn shell on a HP but the code will also run on AIX.
The code is very big but here is the piece that is not working

if [ "${ALERT}" ]
then
set -x
desc="performing maintenance on the Oracle alerts logs."
echo "\n${desc}\n" >> ${logfile}

export dblist=$(grep -v "#" ${oratab} | awk -F: '{print $1}')
echo "${dblist}" | while read db
do
while true
do
export sid=${db}
alertlog="alert_${sid}.log"
echo "\nprocessing ${alertlog}." >> ${logfile}
orauser=${admin}/${sid}/.orauser_${sid}
if test ! -r "${orauser}"
then
errmsg=${main}.${today}.msg
echo "unable to read ${orauser}" > ${errmsg}
send_message ${maillist} ${errmsg}
echo "\nunable to read ${orauser}." >> ${logfile}
break
fi
. ${admin}/${sid}/.orauser_${sid}
echo "\nsql query for background_dump_desc from ${sid}." >> ${logfile}
sqlcmd=${workdir}/${main}.alertlog.${today}.sql
sqllog=${workdir}/${main}.alertlog.${today}.log
rm -f ${sqlcmd} ${sqllog}
echo "set termout off" > ${sqlcmd}
echo "set pagesize 0" >> ${sqlcmd}
echo "set linesize 1024" >> ${sqlcmd}
echo "set trimspool on" >> ${sqlcmd}
echo "set heading off" >> ${sqlcmd}
echo "set feedback off" >> ${sqlcmd}
echo "set verify off" >> ${sqlcmd}
echo "whenever sqlerror warning" >> ${sqlcmd}
echo "spool ${sqllog}" >> ${sqlcmd}
echo "select value from v\$parameter" >> ${sqlcmd}
echo " where name = 'background_dump_dest';" >> ${sqlcmd}
echo "exit" >> ${sqlcmd}
systempwd=$(get_pwd ${node} ${sid} system)
(sqlplus -S system/${systempwd} @${sqlcmd}) >> ${logfile}
if [ "${status}" -ne 0 ]
then
errmsg=${main}.${today}.msg
echo "error ${status} retriving background_dump_dest \c" >> ${logfile}
echo "from ${sid}." > ${errmsg}
send_message ${maillist} ${errmsg}
echo "error ${status} retriving background_dump_dest \c" >> ${logfile}
echo "from ${sid}." >> ${logfile}
break
fi
bdump=$(cat ${sqllog})
echo "\nsqlplus query successful. bdump = ${bdump}\n" >> ${logfile}
rm -f ${sqlcmd} ${sqllog}
timestamp=$(gettimestamp)
archive="${alertlog}.${timestamp}"
cp -fp ${bdump}/${alertlog} ${bdump}/${archive}
echo "\narchiving ${alertlog} to TSM." >> ${logfile}
archive_file ${bdump} ${archive} ${mca}
status=$?
if [ "${status}" -ne 0 ]
then
errmsg=${main}.${today}.msg
echo "error ${status} archiving ${archive} to TSM." > ${errmsg}
send_message ${maillist} ${errmsg}
echo "error ${status} archiving ${archive} to TSM." >> ${logfile}
echo "restoring ${alertlog} to original state." >> ${logfile}
tmpfile=${workdir}/${main}.tmp

cmd="cat ${bdump}/${archive} ${bdump}/${alertlog} > ${tmpfile}; "
cmd="${cmd} mv -f ${tmpfile} ${bdump}/${alertlog}; "
cmd="rm -f ${bdump}/${archive} ${tmpfile}"
(${cmd})
break
fi
rm -f ${bdump}/${archive}
echo "\ntruncating file ${bdump}/${alertlog}" >> ${logfile}
truncate_file ${bdump}/${alertlog}
status=$?
if [ "${status}" -ne 0 ]
then
errmsg=${main}.${today}.msg
echo "error ${status} truncating ${bdump}\c" > ${errmsg}
echo "/${alertlog}." >> ${errmsg}
send_message ${maillist} ${errmsg}
echo "error ${status} truncating ${bdump}/\c" >> ${logfile}
echo "${alertlog}." >> ${logfile}
continue
fi
echo "\nfile truncated successfully.\n" >> ${logfile}
break
done
done
fi
  #4 (permalink)  
Old 04-15-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
I would like to see printing dblist after the following line
to see what it is printing and whether dblist is just a single line.

export dblist=$(grep -v "#" ${oratab} | awk -F: '{print $1}')


Also print some log between those 2 'done' statements and see whether it is printed or not.



done
done
  #5 (permalink)  
Old 04-15-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by bhargav
export dblist=$(grep -v "#" ${oratab} | awk -F: '{print $1}')
export dblist=$(awk -F: '/^[^#].*/ {print $1}' ${oratab})
  #6 (permalink)  
Old 04-20-2005
chinog chinog is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 4
Thank you for all your help I change the command line and work fine. I don't now how this work but if you can explain to me why this command works and not the original one will be helpfull. Thank you again
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0