fix bugs & add logging to nameget.sh
authorAndrew Lorimer <andrew@lorimer.id.au>
Tue, 17 Jul 2018 14:15:49 +0000 (00:15 +1000)
committerAndrew Lorimer <andrew@lorimer.id.au>
Tue, 17 Jul 2018 14:15:49 +0000 (00:15 +1000)
nameget.sh
index c0088ab2be47925263153b92f9b33667d6f24464..4c19b8bf7057b457670eb8aadb6d0eb0498f597e 100755 (executable)
@@ -2,6 +2,7 @@
 
 # get a list of urls and corresponding output file names, then parse them to wget
 
+LOGTAG="nameget.sh"
 args=("$@")
 list=${args[0]}
 
@@ -24,8 +25,13 @@ fi
 
 otherargs=$@                                                                                                   # set aside remaining arguments for passing to wget
 
+logger -s -t $LOGTAG "starting downloading files in $list"
+
 while read -r url filename tail; do
-  if wget --cut-dirs=100 -r -np -nc --accept -e robots=off -O "$outdir$filename" "$url" $otherargs
+  if wget --cut-dirs=100 -np --accept -e robots=off -O "$outdir$filename" "$url" $otherargs; then
                sed '/$filename/d' $list
+               logger -s -t $LOGTAG "downloaded $filename"
+       else
+               logger -s -t $LOGTAG "downloading of $filename from $url failed."
        fi
 done < $list