I currently run a script over a vpnc tunnel to back-up my data to a remote server. However for a number of reasons the tunnel often collapses. If I manually restore the tunnel then the whole thing can continue, but I want to add into my script a section whereby while the transfer is taking place, the system checks if the tunnel is still up and if not it resets it. I though I had it cracked (see below), but even though the $BREAK variablet change after the process code had run, it didn't escape the while loop so the script never ended. I therefore think I need a different way of doing it (by the way I am new to scripting so expect some ugly code).....
I am not asking someone to write this for me, but if you know of a function that I could use that would be most helpful..... Thanks in advance.....
Code:
function process ()
{
process code.....
BREAK=500
}
# ------------- the script itself --------------------------------------
BREAK=0
# First run Tunnel to get it up and running (a separate script).
Tunnel.sh
# Run process and the while loop at the same time.
process &
while [ $BREAK == 0 ]
do
Tunnel.sh #Re-establishes connection if required
sleep 15
done