Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • T Transfer Tool
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Clinbio
  • SPSP NG
  • Transfer Tool
  • Issues
  • #9
Closed
Open
Issue created Feb 08, 2022 by Dillenn Terumalai@dterumalOwner

The test reports success even if the sftp command failed

Summary

The script reports success even if the transfer (sftp command) actually failed

Steps to reproduce

What is the current bug behavior?

-  Initializing the automatic mode of the Transfer Tool...  DONE
-  Testing the connection to the remote server...           DONE
-  Compressing the viruses and bacteria subfolders...       DONE
-  Hashing and encrypting the archives...                   DONE
-  Transferring the encrypted archives...                   DONE
 
DONE  Transfer completed. 78 files has been securely transferred to the secured server.
 
Time: 25 s
 
DONE  Test completed. Everything went smoothly.

What is the expected correct behavior?

-  Initializing the automatic mode of the Transfer Tool...  DONE
-  Testing the connection to the remote server...           DONE
-  Compressing the viruses and bacteria subfolders...       DONE
-  Hashing and encrypting the archives...                   DONE
-  Transferring the encrypted archives...                   ERROR

Relevant screenshots and/or logs

Uwe Schmidt uwe.schmitt@id.ethz.ch nicely fixed the bug with the following modifications:

diff --git a/spsp b/spsp
index b66d03f..c025451 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 -q -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 -q -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"
@@ -473,16 +487,17 @@ autoMode() {
     printf "${BACK_GREEN} DONE ${COL_RESET}\n"
   fi
 
-  if [[ $SUCCESS > 0 ]]; then
-    printf "\n${BACK_GREEN} DONE ${COL_RESET} Transfer completed. $SUCCESS files has been securely transferred to the secured server.\n\n"
-  fi
-
   if [[ $ERRORS > 0 ]]; then
     printf "${BACK_RED} ERROR ${COL_RESET} ${COL_RED}Completed with $ERRORS error(s)${COL_RESET} ${COL_GREY} ${TIME} ${COL_RESET}\n"
     printf "${BACK_RED} error ${COL_RESET} Error detected: Please check ./$ERRORLOGFILE\n"
     exit 1
   fi
 
+  if [[ $SUCCESS > 0 ]]; then
+    printf "\n${BACK_GREEN} DONE ${COL_RESET} Transfer completed. $SUCCESS files has been securely transferred to the secured server.\n\n"
+  fi
+
+
   END=$(date +%s)
   DIFF=$(($END - $START))
   echo "Time: $DIFF s"
Edited Feb 08, 2022 by Dillenn Terumalai
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking