From: Andrew Lorimer Date: Wed, 15 Jun 2022 02:27:13 +0000 (+1000) Subject: nameget.sh bugfixing X-Git-Url: https://git.lorimer.id.au/scripts.git/diff_plain/347d06cc67a76b8e9c9acf5d54d39e3236c8f521 nameget.sh bugfixing --- diff --git a/nameget.sh b/nameget.sh index 063544c..943ce75 100755 --- a/nameget.sh +++ b/nameget.sh @@ -5,7 +5,7 @@ # Andrew Lorimer https://lorimer.id.au # -VERSION="0.9" +VERSION="1.0" LOGTAG="$(basename "$0")" LOGFILE=/var/log/nameget BADWORDS="error\|failure\|unable\|denied\|directory" @@ -42,7 +42,7 @@ Get a list of urls and optional corresponding output paths, then send them to wg -n, --number Maximum number of files to download - Default: none + Default: no limit -a, --args \e[4m\e[0m String of shell arguments which are passed verbatim to wget\n" @@ -60,6 +60,8 @@ fi # Validate arguments # +list='queue.txt' + while [ $# -gt 0 ]; do case "$1" in -l|--list) @@ -132,7 +134,7 @@ if [[ ! $outdir =~ /$ ]]; then # check if [DESTINATION] has a trailing / fi # -# Recurse through list +# Iterate through list # @@ -166,11 +168,7 @@ while read -r url filename; do if [ "$test" ]; then output "$command" " " else - if [ "$EUID" -ne 0 ]; then # get stdout of command - wgetout=$($command | tee /dev/tty) # get stdout of command - else - wgetout=$($command 2>&1 > /dev/null) # get stderr of command - fi + wgetout=$(bash -c "($command)" 2>&1) # get stdout of command exitcode=$? failures=$(echo "$wgetout" | grep -i "$badwords") if [ $exitcode -eq 0 ] && [ -z "$failures" ]; then