From: Andrew Lorimer Date: Mon, 24 Dec 2018 04:21:54 +0000 (+1100) Subject: optional destination file, verbose debugging for wget in syslog X-Git-Url: https://git.lorimer.id.au/scripts.git/diff_plain/f63497ac860cb389b0afc27e420f95129dc3ea05?hp=05a9d272b0c9372b3a1dfbaa9752ea332b63a170 optional destination file, verbose debugging for wget in syslog --- diff --git a/nameget.sh b/nameget.sh index edc1e2e..b083568 100755 --- a/nameget.sh +++ b/nameget.sh @@ -28,11 +28,15 @@ otherargs=$@ # set aside remaining arguments for passing to wget logger -s -t $LOGTAG "starting downloading files in $list" while read -r url filename; do - if wget --cut-dirs=100 -np -e robots=off -O $outdir$filename $otherargs $url; then + destarg = '' + if [ -n "$filename" ]; then + $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." + logger -s -t $LOGTAG "downloading of $filename from $url failed: $output" fi done < $list