The loop that dosent work


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers The loop that dosent work
# 8  
Old 01-10-2008
This is valid ksh syntax....
Code:
$ cat num
10
$ echo $(< num)
10
$ echo `< num`
10
$ [ -a num ] && echo ok
ok
$

$(< num) is the contents of the file called num. I have seen this often. I have never seen `< num` before and it is not documented, but it seems to work. Many versions of ksh allow -a or -e to test if an item is a file sysetm object of any kind (not just a file, not just a directory, not just a symlink, etc). But -e and -a are not super standard even among versions of ksh.
# 9  
Old 01-10-2008
i think its also benefiical if you show your other .sh scripts as well.
# 10  
Old 01-11-2008
I agree about needing more info. A loop must initialize a loop counter, increment it, and test it. I see one script that sets /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log to zero. And another that tests it. No increment though. And I do not see how these script fragments inter-relate. Smilie
# 11  
Old 01-11-2008
also, using kill -15 is a better way to stop a runaway program than to do a chmod -x on something.
# 12  
Old 01-11-2008
I was hopeing not to burden you with all the ugly details of the other .sh but you asked for it Smilie

Code:
#!/bin/bash -x
. /export/home/mldwh/rkem_refresh/int_load/scripts/rkem_functions.sh

######Set Path Variables
Path_Variables /export/home/mldwh/rkem_refresh/logs/ rkem_master.log


######Set Username and Password Variables
Username_Variables $RKEM_LOG rkem_master.log


######Capture MainFrame Time
RKEM_Mainframe_time $RKEM_LOG rkem_master.log $IDB1USER $IDB1PWD


######Set Master Date Variable
Master_date $RKEM_LOG rkem_master.log


######Audit Process Start
Process_Audit_Start $RKEM_LOG rkem_master.log $TPCUSER $TPCPWD $MASTERDATE "'RKEM REFRESH'" 'Start RKEM Delta Load'


######Start Full Process File
echo -==Create Start and Stop files==- >> $RKEM_LOG"rkem_master.log"
db2 -x "select rtrim(char(year(max(CHDATETIME)))) || '-' || substr( digits (month(max(CHDATETIME))),9) || '-' || substr( digits (day(max(CHDATETIME))),9) From CENDW.DW_RKEM_MOVE_TBL" > $RKEM_LOG"rkem_start_date.txt"
db2 -x "select substr( digits (hour(max(CHDATETIME))),9) || '.' || substr( digits (minute(max(CHDATETIME))),9) || '.' || substr( digits (second(max(CHDATETIME))),9) From CENDW.DW_RKEM_MOVE_TBL" > $RKEM_LOG"rkem_start_time.txt"
echo -== Start Date `cat $RKEM_LOG"rkem_start_date.txt"`==- >> $RKEM_LOG"rkem_master.log"
echo --==Start time `cat $RKEM_LOG"rkem_start_time.txt"`==- >> $RKEM_LOG"rkem_master.log"


######Create Hold File for RKEM Load Process
Hold_File $RKEM_LOG rkem_master.log 'RKEM MOVE DELTA REFRESH RUNNING' int_rkem_move_running.txt


######Call RKEM MOVE Extract PROCESS
RKEM_Call_Process $RKEM_LOG rkem_master.log $RKEM_SCRIPT extract_rkem_move.sh 'Start RKEM Process'


sleep 15


######Call RKEM MOVE Load PROCESS
RKEM_Call_Process $RKEM_LOG rkem_master.log $RKEM_SCRIPT load_rkem_move.sh 'Call $RKEM_SCRIPT"load_rkem_move.sh"'


######Wait for RKEM MOVE PROCESS to Complete
File_Wait $RKEM_LOG rkem_master.log rkem_move_delta_running.txt 'Start time waiting for STG RKEM to load' 'Finish time waiting for STG RKEM to load'


######Test that Load completed
Process_Test $RKEM_LOG rkem_master.log "'RKEM REFRESH'" "'RKEM REFRESH - RKEM MOVE'" $MASTERDATE $RKEM_SCRIPT merge_rkem_move.sh 'RKEM STG LOAD INCOMPLETE' INCOMPLETE_RKEM_STG_LOAD.TXT


sleep 15


######Wait for RKEM MOVE MERGE PROCESS to Complete
File_Wait $RKEM_LOG rkem_master.log rkem_move_merge_running.txt 'Start time waiting for STG RKEM MERGE ' 'Finish time waiting for STG RKEM MERGE'


######Test that Merge completed
Process_Test $RKEM_LOG rkem_master.log "'RKEM REFRESH'" "'RKEM REFRESH - MERGE RKEM MOVE'" $MASTERDATE $RKEM_SCRIPT merge_rkem_move_update.sh 'RKEM MOVE MERGE INCOMPLETE' INCOMPLETE_RKEM_MOVE_MERGE.TXT


sleep 15


######Wait for RKEM MOVE MERGE UPDATE PROCESS to Complete
File_Wait $RKEM_LOG rkem_master.log rkem_move_update_merge_running.txt 'Start time waiting for RKEM UPDATE MERGE' 'Finish time waiting for RKEM UPDATE MERGE'


######Test that Update Merge completed
Process_Test $RKEM_LOG rkem_master.log "'RKEM REFRESH'" "'RKEM REFRESH - MERGE RKEM MOVE UPDATE'" $MASTERDATE $RKEM_SCRIPT update_rkem_move.sh 'RKEM MOVE UPDATE MERGE INCOMPLETE' INCOMPLETE_RKEM_MOVE_UPDATE_MERGE.TXT


sleep 15


######Wait for RKEM MOVE UPDATE PROCESS to Complete
File_Wait $RKEM_LOG rkem_master.log rkem_move_update_running.txt 'Start time waiting for RKEM MOVE UPDATE ' 'Finish time waiting for RKEM MOVE UPDATE'


######Test that Update completed
Last_Process_Test $RKEM_LOG rkem_master.log "'RKEM REFRESH'" "'RKEM REFRESH - UPDATE'" $MASTERDATE 'RKEM MOVE UPDATE INCOMPLETE' INCOMPLETE_RKEM_MOVE_UPDATE.TXT


######Audit FULL PROCESS
Process_Audit_Stop $RKEM_LOG rkem_master.log $TPCUSER $TPCPWD "'RKEM REFRESH'" 'Finish RKEM Delta Load'


######Set Iteration Log
value=`< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log`
final=`expr $value + 1`
echo $final > /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log


######Remove Hold File for RKEM Load
Remove_Hold_file $RKEM_LOG rkem_master.log int_rkem_move_running.txt

Notice near the bottom where I set the iteration log

Code:
######Set Iteration Log
value=`< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log`
final=`expr $value + 1`
echo $final > /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log

Does this shed more light onto the problem? Im realy behind on a deadline and I need this loop to work so that I can enjoy the vacation that I am on. Any info would be great
# 13  
Old 01-11-2008
and now a bigger problem

kill -15 isnt killing the pids....
 
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