optional destination file, verbose debugging for wget in syslog
authorAndrew Lorimer <andrew@charles.cortex>
Mon, 24 Dec 2018 04:21:54 +0000 (15:21 +1100)
committerAndrew Lorimer <andrew@charles.cortex>
Mon, 24 Dec 2018 04:21:54 +0000 (15:21 +1100)
nameget.sh
index edc1e2e27b89c6ecf1ba30e63a96a741be2ca2a8..b0835689b9a6b181b4c3c22ace1fc3162a9a49b1 100755 (executable)
@@ -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