if no file then quit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting if no file then quit
# 1  
Old 09-08-2010
if no file then quit

I have a script that run several subscripts. I need to find out how to do two things. First I would like to check for a file and if that file is not there I want to quit the entire script without running the rest of the script which contain subscripts. If the file is there, I want it to continue running.

I would also like to know how to tell it to try again in 1 hour but only up to three times. I already have a script that runs twice daily and just want to insert the script in the existing code.
# 2  
Old 09-08-2010
Code:
if [ ! -f "/my/file" ] ; then
   exit 0;
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. OS X (Apple)

Are you sure you want to quit Safari?

Hmmm. I cannot figure out where to disable this warning message in Safari. Google says to disable something in Safari Tabs preferences but my Macs do not have that option in Mojave. Anyone know how to disable the following so when I quit Safari it simply quits without the "freeze the... (12 Replies)
Discussion started by: Neo
12 Replies

2. Shell Programming and Scripting

Need to quit out of for loop.

Hi, Here is my code to send read.txt to three servers. col="prd167.mybank.com prd168.mybank.com bsprd169.mybank.com" set -A look $col for IndixList in ${look}; do scp /tmp/read.txt admin@$IndixList:/tmp done This works and all the 3 servers gets the read.txt file. However,... (8 Replies)
Discussion started by: mohtashims
8 Replies

3. Shell Programming and Scripting

Opening a file in vi and automatically save and quit this file using shell script

Hi friends, In my shell script, I want to open a file using vi editor. After opening the file in vi, I want to save and quit this file automatically.... all through shell script. the code segment is: ------------------------------------------------------------ cd ~/netfpga/projects/scone/sw/... (2 Replies)
Discussion started by: sachinteotia
2 Replies

4. Shell Programming and Scripting

How to quit from a script?

hi all, I am facing problem in shell scripting while using exit command, when ever i run a file using . ./<filename>, when i run the sae script as sh <filename> the script does not close the windows. since my script has function calls i have to use . ./ <filename>. Could any one tell me... (8 Replies)
Discussion started by: caro
8 Replies

5. Shell Programming and Scripting

perl how to exit a while loop and quit reading the input file

I am reading a file using While loop while <FILE> { $_ = <FILE>; process data... } I would like to quit reading the file once I encounter a String pattern. How do i do it. is it if (/SUMMARY/) { last; } I am having problems with uninitialized value in pattern... (1 Reply)
Discussion started by: subhap
1 Replies

6. UNIX for Dummies Questions & Answers

detect file size then quit or continue

Hi Guys, I'm running a cron that mails me a file every night. The file is based on form input from the web and each evening after I mail it I delete and start a new file by the same name. It's a csv file so I preload a line of headers into the file. So far, so good. On days when no one inputs... (5 Replies)
Discussion started by: steven99
5 Replies

7. Shell Programming and Scripting

quit any time

how can i read input to quit any time, for instance "type q to quit" I have a script like this echo "The first choice" read firstChoice echo "The second choice" read secondChoice Looking for a code to quit any time by pressing q to quit any help would be appreciated thanks (5 Replies)
Discussion started by: Qwond
5 Replies

8. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies

9. UNIX for Dummies Questions & Answers

how to quit from glance

hi, if i am in glance, how do i exit? thanks (2 Replies)
Discussion started by: yls177
2 Replies
Login or Register to Ask a Question