The loop that dosent work


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers The loop that dosent work
# 1  
Old 01-10-2008
The loop that dosent work

I have a serious problem and Im sure im just doing something stupid

Code:
######Start Load 
while [ `< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log` -lt 15 ]
do
         /export/home/mldwh/rkem_refresh/int_load/scripts/rkem_refresh.sh
         sleep 10
         while [ -a /export/home/mldwh/rkem_refresh/int_load/logs/int_rkem_move_running.txt ]
         do 
   					sleep 5 
				done
done


######Log and Runstats 
sleep 10
echo "2nd 15 iterations finished" >> /export/home/mldwh/rkem_refresh/int_load/logs/Int_master.log
echo 0 > /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log
db2 "CALL SYSPROC.ADMIN_CMD('runstats on table CENDW.DW_RKEM_MOVE_TBL with distribution and detailed indexes all shrlevel change')" >> /export/home/mldwh/rkem_refresh/int_load/logs/Int_master.log
db2 "CALL SYSPROC.ADMIN_CMD('runstats on table CENDW.DW_RKEM_MOVE_UPDATE_TBL with distribution and detailed indexes all shrlevel change')" >> /export/home/mldwh/rkem_refresh/int_load/logs/Int_master.log
sleep 10


######Start Load 
while [ `< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log` -lt 15 ]
do
         /export/home/mldwh/rkem_refresh/int_load/scripts/rkem_refresh.sh
         sleep 10
         while [ -a /export/home/mldwh/rkem_refresh/int_load/logs/int_rkem_move_running.txt ]
         do 
   					sleep 5 
				done
done

What I want to do is run the .sh file 15 times and then do some stuff and then run the .sh file 15 times again. I put the loop inside the loop (where i think my problem is) to make sure that the outer loop waited untill the .sh file was done before calling it again.

But what I am getting......ohh man this thing is spawning so many instances of the code that I have to chmod -x just to stop it.

So where am i going wrong?
# 2  
Old 01-10-2008
Quote:
Originally Posted by jadionne
Code:
while [ `< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log` -lt 15 ]

Quote:
Originally Posted by jadionne
Code:
while [ -a /export/home/mldwh/rkem_refresh/int_load/logs/int_rkem_move_running.txt ]

What shell are you running that in? - it's not valid bourne at any rate...
# 3  
Old 01-10-2008
Quote:
Originally Posted by jadionne
But what I am getting......ohh man this thing is spawning so many instances of the code that I have to chmod -x just to stop it.

So where am i going wrong?
you specified a while loop that do repetition if some counter is less than 15. Where is the counter? I presume its the value in the iteration.log file and int_rkem_move_running.txt files? if it is, then you have to update them to reflect a new counter everytime.
# 4  
Old 01-10-2008
Quote:
Originally Posted by Smiling Dragon
What shell are you running that in? - it's not valid bourne at any rate...
Im in ksh...

Im lost regarding your post. are both of these supposed to be imbeded in each other?....how do i use this info?
# 5  
Old 01-10-2008
Quote:
Originally Posted by ghostdog74
you specified a while loop that do repetition if some counter is less than 15. Where is the counter? I presume its the value in the iteration.log file and int_rkem_move_running.txt files? if it is, then you have to update them to reflect a new counter everytime.
The counter is in the iteration.log file and it is incrmented durring the last step of the .sh file

the int_rkem_move_running.txt is a "seed" file that is created at the begining of the .sh script and deleted at the end of the .sh script.

The iteration seems to work I see it loop, but for some reason it seems to call the .sh file many times before it finishes. I.E. the loop isnt waiting for the .sh to finish before it calls another one.

I dont get it....
# 6  
Old 01-10-2008
Quote:
Originally Posted by jadionne
Im in ksh...

Im lost regarding your post. are both of these supposed to be imbeded in each other?....how do i use this info?
I'm just noting that those two lines I quoted are not valid in bourne - thus prompting the question of which shell.

The `< file` thing is unique to ksh as far as I can tell and is an aliase for wc
The -a makes no sense to me at all - I'm used to it being a logical and between two expressions.
# 7  
Old 01-10-2008
Quote:
Originally Posted by Smiling Dragon
I'm just noting that those two lines I quoted are not valid in bourne - thus prompting the question of which shell.

The `< file` thing is unique to ksh as far as I can tell and is an aliase for wc
The -a makes no sense to me at all - I'm used to it being a logical and between two expressions.

the -a means while exhists. i only work in ksh right now...

any idea about the loop? im realy stuck here
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why doesnt if inside a while loop work ?

I am looping through a file in bash and performing some operations on it. Here is the code. cat test.dat - One Two Three Case 1: With if inside while loop Output: One file found :) ------------------ isn't it supposed to print following output !!! one (3 Replies)
Discussion started by: qwarentine
3 Replies

2. Shell Programming and Scripting

Variable value dosent change after the loop changes it

i am new to shell scripting. this is similar to the code which i was writing for some other work. i want the variable 'x' to have the value which it will finally have at the end of the loop ( the number of directories ). but the value of 'x' only changes inside the loop and it remains '0' out-side... (3 Replies)
Discussion started by: chathura666
3 Replies

3. Shell Programming and Scripting

Script doesn't work in loop but does if not

I have a script that only works if I remove it from the looping scenario. #!/bin/bash # Set the field seperator to a newline ##IFS=" ##" # Loop through the file ##for line in `cat nlist.txt`;do # put the line into a variable. ##dbuser=$line echo "copying plugin..." ... (6 Replies)
Discussion started by: bugeye
6 Replies

4. Shell Programming and Scripting

Why does my for loop does not work right in ksh?

hi all, i have a for loop statement in my ksh code. it only returns the first value retrieved not the value for the other rows. ex: acct_id value = returned value in the for loop 1 = 1 2 = 1 (instead of 2) 3 = ... (1 Reply)
Discussion started by: ryukishin_17
1 Replies

5. Shell Programming and Scripting

while - loop does not work

Hey guys, maybe you can help me.. what am i doing wrong? Why this doesn`t work in ksh. while do echo "Type y or n" read decision if then doInstall fi done i also tried this ... (6 Replies)
Discussion started by: xcitan
6 Replies

6. Shell Programming and Scripting

loop doesnt work

It just does the break...even though the files are not the same... # Compare extracts #========================================== count=0 while (( count < 5 )) do (( count+=1 )) echo "Try $count" file1=$(ls -l /tmp/psjava.xml|... (5 Replies)
Discussion started by: sigh2010
5 Replies

7. Shell Programming and Scripting

for loop doesn't work

I have a script which uses below for loop: for (( i = 0 ; i <= 5; i++ )) do echo "Welcome $i times" done But when I run the script, it gives error message: Syntex Error : Bad for loop variable Can anyone guide to run it? Thanks in advance. (10 Replies)
Discussion started by: naw_deepak
10 Replies

8. UNIX for Dummies Questions & Answers

Why script For...Loop doesn't work. Seek help

I have written a script to run on UNIX server. When I tested, it always hanged on after "date +"%D %T: XXXXXX script started." part. Then it wouldn't go further. UNIX server gave me one error message. I used the same code in another script. It works fine. I think the major problem may be in... (3 Replies)
Discussion started by: duke0001
3 Replies

9. UNIX for Dummies Questions & Answers

crontab -e dosent work

Hello! my crontab -e dosent work. Im getting this error message: sh: VI: not found The crontab files was not changed. How do i make it work? I think you should use "export editor=vi" or something. But i cant seem to get the correct line! pleas help... (11 Replies)
Discussion started by: dozy
11 Replies

10. UNIX for Dummies Questions & Answers

traceroute dosent work

hi , folks i m back with again some silly question i think.!! i can do ftp , telnet from windows to unix machine , but not vice versa!!! , from unix box , i get connection refused , and ping says not alive. ,...my os . solaris 7 , ok i know ishouldnt load network by using traceroute , but itried... (2 Replies)
Discussion started by: definate
2 Replies
Login or Register to Ask a Question