Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Script Fetches url for n times
- URL="http://www.maaaaaaaaaak.ru"
- PRBLEN=10
- if [ "$#" -lt 1 ]; then
- echo "Usage: $0 <times> [url]"
- echo " times - how much requests should the script do"
- echo " url - URL to examine (default is $URL)"
- exit 255
- fi
- if [ "$2" != "" ]; then URL=$2; fi
- check_bin() {
- if [ `which $1` == "" ]; then
- echo "$1 command not found. Please install $1"
- exit 255
- fi
- }
- if [ `uname -s` == "FreeBSD" ]; then
- FREE_BSD=1
- check_bin "fetch"
- else
- if [ `uname -s` == "Linux" ]; then
- FREE_BSD=0
- check_bin "wget"
- else
- echo Unsupported OS `uname -s`
- exit 255
- fi
- fi
- total=0
- err=0
- while [ "$total" != "$1" ]; do
- if [ $FREE_BSD == "1" ]; then
- fetch -o /dev/null $URL > /dev/null 2>&1
- else
- wget -O /dev/null $URL > /dev/null 2>&1
- fi
- if [ "$?" != "0" ]; then
- ((err=err+1))
- fi
- ((total=total+1))
- ((percent=total*100/$1))
- ((prg=total*PRBLEN/$1))
- printf "\r["
- counter=0
- while [ $counter -lt $PRBLEN ]; do
- if [ $counter -lt $prg ]; then
- echo -n "*"
- else
- echo -n " "
- fi
- ((counter=counter+1))
- done
- echo -n "]" $total/$1 \($percent\%\)
- done
- echo ""
- echo Total: $total
- echo Err: $err
Advertisement
Add Comment
Please, Sign In to add comment