A fun bandwidth tester bash script – endlessdownload.sh

  bash, linux, raspberry-pi
#!/bin/bash


# SET THIS! This is the URL to your large file that
# you're downloading over and over again
URL=http://192.168.0.10/test/a


# use wget to grab the file, redirect to dev null:
COUNTER=0
TOTAL=0
while true; do
  GB=$((TOTAL >> 30))
  MB=$((TOTAL >> 20))


  echo "Run #$COUNTER at `date` Total downloaded $MB MB, $GB GB"
  wget -qO- "$URL" &> /dev/null;


  # Get the file size, remove the carriage return
  DL=`curl -sI "$URL" | grep Content-Length | cut -d ' ' -f 2 | tr -d '\r'`


  let TOTAL=TOTAL+${DL}
  sleep 0;
  let COUNTER=COUNTER+1


done

Example output:

pi@raspberrypi ~ $ ./endlessdownload.sh
Run #0 at Wed Feb 26 22:08:00 EST 2014 Total downloaded 0 MB, 0 GB
Run #1 at Wed Feb 26 22:08:34 EST 2014 Total downloaded 78 MB, 0 GB
Run #2 at Wed Feb 26 22:09:07 EST 2014 Total downloaded 156 MB, 0 GB
Run #3 at Wed Feb 26 22:09:40 EST 2014 Total downloaded 234 MB, 0 GB
Run #4 at Wed Feb 26 22:10:13 EST 2014 Total downloaded 312 MB, 0 GB
Run #5 at Wed Feb 26 22:10:46 EST 2014 Total downloaded 390 MB, 0 GB