From 347d06cc67a76b8e9c9acf5d54d39e3236c8f521 Mon Sep 17 00:00:00 2001 From: Andrew Lorimer Date: Wed, 15 Jun 2022 12:27:13 +1000 Subject: [PATCH 1/1] nameget.sh bugfixing --- nameget.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 -- 2.43.2