It resumes downloads and loops till the file is downloaded. On the anvil-A conf file which can be parsed for list of urls.
It even shuts down after a predetermined interval.
#!/bin/bash
url="$1"
#export CURLOPT_CONNECTTIMEOUT=200000
#export CURLOPT_TIMEOUT=200000#See if the last char in path is a slash. Else add it
#lchr=`expr substr $targetDIR ${#targetDIR} 1`
#lchr=${targetDIR#${targetDIR%?}}
minstoshutdown=120sudo shutdown -h +$minstoshutdown &
sleeptime=10
syntax="\
Syntax:
cdown [URL]"if [ "$url" = "" ]
then
echo "You need to url a file to upload!"
echo $syntax
exit 1
ficoman="curl -C - -J -O $url"
echo "Command is :"
echo $comanexcode=1
text="Starting download...."
tries=0while [ "$excode" -ne "0" ];
do
echo
let tries++
echo $text$tries
eval $comanexcode=$?
echo
echo "Exited with code - $excode"
echo
if [ "$excode" -eq "6" ]
then
echo "Your internet connection seems to be down!"
fi
echo "Waiting $sleeptime secs before trying again..."
sleep $sleeptime;
text="Restarting download...Attempt No: "
doneif [ "$excode" -eq "0" ]
then
echo "Completed upload after $tries tries"
else
echo "Tried $tries times. Upload was interrupted."
fi[/code]
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.