while loop checking for file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting while loop checking for file
# 1  
Old 01-18-2012
while loop checking for file

Hi

I my shell scripting(Main.ksh) i am calling the another loader.ksh using nohup inside the for loop ...so the above command runs parallel. Loader.ksh generate the dummy file seq_n.run file and deleted in the end of the Loader.ksh

In the main.ksh .. after the for loop .. i have to check the *.run file are not there in the while loop or while loop for 2 hr to come out ..

Could some one help to build the while loop.
# 2  
Old 01-18-2012
Try to put this into psuedo code. From what your saying, I interpret your psuedo code to look something like the following:

Main.ksh
Code:
while <condition: filename "*.run" exists>
do
  <optional: do some processing here>
  for <variable> in <condition: ???>
  do
    <optional: do some processing here> 
    run loader.ksh
    <optional: do some processing here>
  done  # for loop
  <optional: do some processing here>
  wait 2 hours
done # while loop

I assume your "for loop" is so that you can run multiple loader.ksh files? I don't know the condition for such, that would be for you to determine.

Also, "nohup" will not run loader.ksh in parallel. It will allow loader.ksh to continue even if the Main.ksh process is killed. You need the ampersand (&) in order to make it so that the Main.ksh script does not wait for loader.ksh to finish, which would allow you to run multiple loader.ksh scripts. You can apply both if that is your desire,
i.e.

Code:
 
nohup ksh loader.ksh &

In the psuedo code, I'm just stating that you "run loader.ksh" so that the details can be worked out when more information is known. You should understand that these are separate conditions with different commands/modifiers (nohup and '&').
This User Gave Thanks to rwuerth For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking for substring in a loop takes too long to complete.

I need to check if the files returned by ls command in the below script is a sub-string of the argument passed to the script i.e $1 The below script works fine but is too slow. If the ls command take 12 secs to complete printing all files with while loop then; using posix substring check... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. Shell Programming and Scripting

For loop without checking file exists

In several scripts that process files matched by name pattern I needed to add a check for file existence. Just to illustrate let's say I need to process all N??? files: /tmp$ touch N100 N101 /tmp$ l ?10 -rw-rw-r-- 1 moss group 0 Apr 19 11:22 N100 -rw-rw-r-- 1 moss group ... (10 Replies)
Discussion started by: migurus
10 Replies

3. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies

4. Shell Programming and Scripting

Record count checking for multiple files through for-loop

Hi Friends, I wrote one shell script to check the record count in two files and that will send us the notification activity if found zero record count. What i did is I created for loop and checking the count for both of the files but what is happening is for first file has data then it's... (13 Replies)
Discussion started by: victory
13 Replies

5. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

6. Shell Programming and Scripting

Process checking loop

Hi, I want to create a script who will check if the java process is running & if it finds the process is still there it continues to execute & when the process completes it exit from the script. I have written a code to check & notify the process existence but i am not getting how to write... (4 Replies)
Discussion started by: d8011
4 Replies

7. Shell Programming and Scripting

Script check for file, alert if not there, and continue checking until file arrives

All, Is there a way to keep checking for a file over and over again in the same script for an interval of time? Ie If { mail -user continue checking until file arrives file arrives tasks exit I don't want the script to run each time and email the user each time a file... (4 Replies)
Discussion started by: markdjones82
4 Replies

8. UNIX for Dummies Questions & Answers

For loop for checking processes

Hi Gang, I need part of my script to be able to loop, check for processes running and if they aren't running, start them. It needs to loop 5 times, do a check each time, and make sure a process starts, and if its running; skip it. I've worked with loops and checking for processes before,... (8 Replies)
Discussion started by: jeffs42885
8 Replies

9. Shell Programming and Scripting

bash if loop for checking multiple parameters

Hello, I've got next problem: I want to examine at the beginning of a script in an if loop that: 1. Is there 4 parameters given 2. If first state is true then: is there switches -e and -d? 3. At the end, how can i indentify them as variebles regardlees to its order. I was thinking like... (2 Replies)
Discussion started by: szittyafergeteg
2 Replies

10. Shell Programming and Scripting

Checking condition inside the loop

Hi all, I have one clarification i am using the loop which will process for each record .suppose there is f ailure in the first record it need to send mail and process the next .my code: defcount=`cat <filename>|wc -l` while ] do if <some condiotion> then echo "mail" fi done so... (1 Reply)
Discussion started by: ithirak17
1 Replies
Login or Register to Ask a Question