Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Anti-Throttling GET
- # This script has a problem where the filename
- # has to be listed before any options or the
- # program chokes. I'm too lazy to fix it. :P
- file="$1"
- shift
- declare -i timeout=5
- declare -i randbase=500
- while getopts ":T:R:" opt
- do
- case $opt in
- T) let timeout=$OPTARG;;
- R) let randbase=$OPTARG;;
- \?) echo "Invalid option: -$OPTARG" >&2;;
- esac
- done
- while true
- do
- wget -c -T $timeout "$file"
- declare -i p=$randbase*100 # 1/100 seconds base
- declare -i q=$RANDOM%$p+1 # 1/100 seconds delay
- declare -i r=$q*10000 # microseconds delay
- declare -i s=$q%100 # fractional part
- declare -i t=$q/100 # integer part
- echo "Waiting $t.$s seconds..."
- usleep $r
- unset p q r s t
- done
Add Comment
Please, Sign In to add comment