Script execution dependent upon a file landing in a certain directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script execution dependent upon a file landing in a certain directory
# 1  
Old 04-14-2005
Script execution dependent upon a file landing in a certain directory

Hi all,

I'm looking to write a script that is dependent upon the existence of 2 files each in separate directories. My thought was to do:
**psuedo code **

execute script
check directory 1 for file1
if file exists then
execute script 2 ( checking directory 2 for file 2)
else
wait 30 min, check directory 1

I suppose I could do this with a loop or a while statement, however, I'm unsure of the exact syntax for the check for file/wait for file statement... and the 30 min delay.

Any help would be appreciated.

P.S. This site is amazing, very informative, and very nicely done!!!
# 2  
Old 04-14-2005
Not putting the whole script ....
But following small snippet may be helpful for you to start with or
expand

Code:
if test -f $dir1/file1
then
 echo "FOUND"
fi



Check the syntax for 'while' for looping.

man sleep for waiting ...
# 3  
Old 04-14-2005
Thanks for the starting point, much obliged.
# 4  
Old 12-27-2007
What if I want to check if the file is there before executing.

if [ $FLAG='y' ]
then
while [ ! -f flag.running ]
do
echo "script is still running ...."
sleep 100
done
else
touch flag.running
${SCR_NAME}.ksh ${PARAM} >${SCR_NAME}.log
fi
rm flag.running

this block will be put in 2 scripts.. which ever script will run first , the other script will have to wait. So i have put the flag .
My question is how to put a while loop to check till when the file is removed .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Print Line as per the dependent sequence in shell script.

Hi i have a file like this as shown below: DA PROCESS_ID IDENTIFIER DA_FILE STATUS WAITING_FOR SCOPED_DEPENDENT 1836 21000 01052019 BH90P.TEMP.DA1836.FTP W NULL ... (6 Replies)
Discussion started by: krishnaswarnkar
6 Replies

2. What is on Your Mind?

New UserCP Landing Page (version 0.48)

There is a know bug deep in the Javascript library d3.js which causes an intermediate charting rendering bug in Vue.js. In a nutshell, when a page is reloaded the chart data is not rendered sometimes, but when the Vue.js route changes (a menu item in the UserCP is selected), it works flawlessly.... (3 Replies)
Discussion started by: Neo
3 Replies

3. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

4. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

5. Shell Programming and Scripting

Ed command execution in script file

for file in File_Name* do ed -s $file << 'EOF' 0a $Header_Record . $a . w EOF done The above command is executing in the unix box but is not... (2 Replies)
Discussion started by: Kanch
2 Replies

6. Shell Programming and Scripting

Landing location after FTP.

Hi, I have a requirement that my server receives files from a third party. For this a new user(vendor) has been created and given to the vendor with the default home directory as /home/vendor on my server where he will be placed as soon as he logs into my server. Due to space issues on /home I... (2 Replies)
Discussion started by: bubba27
2 Replies

7. Shell Programming and Scripting

Execution Output of a shell script into a file.

Hi Experts, I have a script called test.sh. I am trying to execute it with sh -x test.sh. Where i can find sequence of steps executed one by one. Now i want to these executions to be captured in a file. i.e sh -x test.sh > output.txt the above one is notworking. can anyone help me... (6 Replies)
Discussion started by: naree
6 Replies

8. Shell Programming and Scripting

Two files one file is dependent and it does not show an output

xxxxx (2 Replies)
Discussion started by: vinayrao
2 Replies

9. UNIX for Dummies Questions & Answers

auto change filemanager folder colors dependent on location in directory hierarchy

Hello, Is it possible to make a file manager use different "colored folders" when browsing specific directories? For example, if I open a gnome file manager and browse my windows share at, smb://192.168.1.101/z/ , can I make those folders appear green? And when I open another instance of... (0 Replies)
Discussion started by: bz43
0 Replies

10. Filesystems, Disks and Memory

How to find Dependent libraries in ELF file?

Dear group, I need to load dependent libraries for an application which is in ELF format.please let me know how to parse the ELF file to find dependent libraries. thnaks in advance, Ravinder (3 Replies)
Discussion started by: ravinder.are
3 Replies
Login or Register to Ask a Question