I have a bash script that uses wget running on a 3g device. I want the script to pause until I get a response so I have setup my code like this:
wget -t 0 -T 15 --retry-connrefused www.example.com
The problem is that when there is no connection at all (3g drops for a few seconds) the DNS can't resolve the host and wget stops retrying.
Is there a way to force retry until the connection comes back? I know I can write a loop but I want to know if there is a setting in wget I can use. If there is not what the best variable to build the loop on?
More details:
With the code I wrote, wget will retry but if the device has no Internet connection at all (for example I pull out the 3g dongle from the device) it will stop retrying telling me it can't resolve the host address. It sends that after the 15 seconds defined by -T 15
wget: unable to resolve host address
This loop should do this:
How it works:
while loopwill not break and it will run thewgetcommand continuously and keep printing error message.wgetstarts resolving the host and getting the files.0orinfi.e unlimited retry, use limited value) ofwgetwill retry to get the files until timeout of 15 seconds reached. After 15 seconds thewgetcommand will fail and print error output and thus thewhile loopwon't break. So it will again reach in a state where there is no connection or such and keep printing error message.wgetstarts resolving the host and getting the files. These steps (1-4) continue as long as the files are not downloaded completely.wgetcommand uses-coption, i.e resume option. So every instances ofwgetwill start (downloading) from where it left off.wgetcommand succeeds, the loop will break.