I have to second bakunin in that your intentions with the script are way less than clear.
Quote:
Originally Posted by
baris35
... When url1 is down for some technical issues, script goes to url2, if url2 is also down, goes to url3.
...
I didn't find (maybe overlooked?) the necessary conditional execution in your script. It will run the
n (up to three) compound commands, one after the other, regardless of the respective exit codes, and loop until
count equals 20. So, 60 commands...
On top, I'm having a hard time to understand your juggling with file descriptors 2 and 3 - what do you want to achieve here?
And, the
PID variable used for the (useless)
trap won't be set anywhere as (
man bash)
Quote:
Special Parameters
.
.
.
! Expands to the process ID of the job most recently placed into the background ...
and you're not running anything in background (which would be pointless anyhow as you want to run additional processes only on failure of the predecessors)
Last but not least, is that on purpose that you
echo "$1 $LINE" in all three branches?