From fd6022ad467ce03cf8159da4caf382eae0418f0d Mon Sep 17 00:00:00 2001 From: Dillenn Terumalai Date: Wed, 16 Feb 2022 14:15:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20a=20bug=20with=20the=20s?= =?UTF-8?q?ftp=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spsp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/spsp b/spsp index b66d03f..4dbfe60 100755 --- a/spsp +++ b/spsp @@ -437,9 +437,16 @@ autoMode() { for FILE in *.*; do if [ -f "$FILE" ]; then - echo put "$FILE" | sftp -q -b- "${SFTP_URL}/$VIRUSES" 1>/dev/null 2>>"../../$ERRORLOGFILE" - ((SUCCESS = SUCCESS + 1)) - echo "[$(date +"%T")] local.SUCCESS: $FILE has been successfully transferred to the remote server" >>"../../$LOGFILE" + echo put "$FILE" | sftp -b- "${SFTP_URL}/$VIRUSES" 2>>"../../$ERRORLOGFILE" 1>&2 + if [[ $? -eq 0 ]]; then + ((SUCCESS = SUCCESS + 1)) + echo "[$(date +"%T")] local.SUCCESS: $FILE has been successfully transferred to the remote server" >>"../../$LOGFILE" + else + ((ERRORS = ERRORS + 1)) + ((STEP_ERRORS = STEP_ERRORS + 1)) + echo "[$(date +"%T")] local.ERROR: sftp transfer of $FILE to ${SFTP_URL}/$VIRUSES failed" >>"../../$LOGFILE" + echo "[$(date +"%F %T")] local.ERROR: sftp transfer of $FILE to ${SFTP_URL}/$VIRUSES failed" >>"../../$ERRORLOGFILE" + fi if [[ "$*" == *--no-archive* ]] || [[ "$*" == *-NA* ]]; then rm -rf "$FILE" echo "[$(date +"%T")] local.SUCCESS: --NA activated, $FILE successfully removed" >>"../../$LOGFILE" @@ -454,9 +461,16 @@ autoMode() { for FILE in *.*; do if [ -f "$FILE" ]; then - echo put "$FILE" | sftp -q -b- -o LogLevel=QUIET "${SFTP_URL}/$BACTERIA" 1>/dev/null 2>>"../../$ERRORLOGFILE" - ((SUCCESS = SUCCESS + 1)) - echo "[$(date +"%T")] local.SUCCESS: $FILE has been successfully transferred to the remote server" >>"../../$LOGFILE" + echo put "$FILE" | sftp -b- "${SFTP_URL}/$BACTERIA" 2>>"../../$ERRORLOGFILE" 1>&2 + if [[ $? -eq 0 ]]; then + ((SUCCESS = SUCCESS + 1)) + echo "[$(date +"%T")] local.SUCCESS: $FILE has been successfully transferred to the remote server" >>"../../$LOGFILE" + else + ((ERRORS = ERRORS + 1)) + ((STEP_ERRORS = STEP_ERRORS + 1)) + echo "[$(date +"%T")] local.ERROR: sftp transfer of $FILE to ${SFTP_URL}/$VIRUSES failed" >>"../../$LOGFILE" + echo "[$(date +"%F %T")] local.ERROR: sftp transfer of $FILE to ${SFTP_URL}/$VIRUSES failed" >>"../../$ERRORLOGFILE" + fi if [[ "$*" == *--no-archive* ]] || [[ "$*" == *-NA* ]]; then rm -rf "$FILE" echo "[$(date +"%T")] local.SUCCESS: --NA activated, $FILE successfully removed" >>"../../$LOGFILE" -- GitLab