#!/bin/sh # # Andy Welter # www.the-welters.com # # This script uses the webcat program to download a list of URLs. # It can be used to repeatadly download the list of files in order to # generate a steady traffic load on a web server, and can also save # the resulting files in a directory. # # Options: # -file # The file name containing the list of URLS to retrieve. # -delay # The number of seconds to pause between GET requests # by default, there is no delay between requests. # -save # The name of an existing directory where the output will # be saved # -loop # The number of times that the script will loop through the file list. # The default is 1. A negative number will cause an infinite loop. # # USAGE="webload -file [-loop ] [-save ] [-delay ]" DELAY=0 LOOP=1 while [ $# -gt 1 ]; do case $1 in -file|-f) URLS=$2 ;; -delay|-d) DELAY=$2 ;; -save|-s) SAVEDIR=$2 ;; -loop|-l) LOOP=$2 ;; *) echo $USAGE exit 1 ;; esac shift 2 done COUNT=0 echo $URLS while [ $COUNT -ne $LOOP ]; do cat $URLS | while read URL; do echo $URL date if [ -n "$SAVEDIR" ]; then FILE=`echo $URL | sed 's,[ /],.,g` webcat $URL > $SAVEDIR/$FILE else webcat $URL > /dev/null fi date echo --------------------- sleep $DELAY done COUNT=`expr $COUNT + 1` done