- $destarg = " -O $outdir$filename"
-
- if output=$(wget --cut-dirs=100 -np -e robots=off -P $outdir$destarg $otherargs $url); then
- sed -i "/$filename/d" $list
- echo $filename
- logger -s -t $LOGTAG "downloaded $filename"
- else
- logger -s -t $LOGTAG "downloading of $filename from $url failed: $output"
- fi
+ destarg=" -O $outdir$filename"
+ prettyname="$filename from $url"
+ else
+ filename=${url##/*/} # extract basename
+ filename=${filename/[ _]/-} # substitute spaces/underscores with dashes
+ filename=$(echo $filename | tr '[:upper:]' '[:lower:]')
+ filename=$(tr -cd "[:print:]\n" < file1)
+ filename=$echo $filename | tr -d
+ fi
+
+ # compile wget command (for debugging purposes)
+ command="wget -r -nv -R "*index.html*" -c -nd -nH --cut-dirs=100 -np -e robots=off -P $outdir$destarg $otherargs $url"
+
+ output=$($command 2>&1) # get stderr of command
+ exitcode=$?
+
+ if [ $exitcode -eq 0 ] || [ `echo $errmsg | grep -i \"$badwords\"` ]; then
+ sed -i '/\"$url\"/d' $list
+ logger -s -t $LOGTAG "downloaded $prettyname" >> $LOGFILE
+ else
+ logger -s -t $LOGTAG "downloading of $prettyname failed with code $exitcode: $(echo $output | sed -n -e 's/.*\(error.*\|failure.*\|unable.*\)$/\1/pI' | paste -sd \; -)" >> $LOGFILE
+ fi