Bash Script and Loop error handling
OK I have another question on bash scripting.
I am writing a script that uses a file that has an array of Computer locations. I use a for loop to go through each one. My question is I test to see if there is communication to the server before moving on. Like I want to copy a file, but I want to test if I can communicate to the site first before attempting. My question is if the communication test fails how would I break out of that current loop so it wouldn't move onto trying to get the files from the server, but go back to the beginning and move on to the next server in the list. I also want to generate an error in a log file that i am creating. I know how to handle the writing into the log, but I am afraid it might continue and try getting the file anyway. Any help would be appreciated. Thanks |
you can simply use the break command
it would go something like this: if (communication is not working) then (write to the log file AND break) Quote:
|
Thank you. I will give that a try.
|
shall i can give the 'N' level in run time
i mean the loop will rotates according to the givan value run time |
You do something like:
Code:
HOSTS="space separated list of machines to try" |
Quote:
Quote:
|
All times are GMT -5. The time now is 10:56 AM. |