0

I am trying to upload all changed files to my FTP server. However, I cannot use -S .tmp and -v when I use the -bb flag - and I can't use those options with ncftpbatch at all. Here is my code:

#!/bin/bash -eo pipefail
IN=$(git diff-tree --no-commit-id --name-only -r HEAD)
OUT=$(echo $IN | tr ";" "\n")
for file in "${OUT[@]}"; do
    ncftpput -bb -S .tmp -v -u "zeussite@kolechia.heliohost.org" -p "*****" ftp.kolechia.heliohost.org "/" $file
done
ncftpbatch

As you can see, I need the -S .tmp to avoid breaking the site during uploads. -v provides output to prevent my CI service from timing out.

How can I upload only the changed files - without temporarily breaking the site? I'm thinking of just logging in separately for each file, but that is bad practice.

  • Why not launch a function in background which just prints dummy values "Like uploading, please wait" and then sleeps for few seconds and do it again. Outside the loop you can kill that background job. – Tarun Lalwani Nov 27 '17 at 09:03
  • @TarunLalwani Everything my program outputs is cached by the CI server - and if the job fails then it is all emailed to me. I don't want an inbox full of "Uploading, please wait... Uploading, please wait...". However, that's a good idea. –  Nov 27 '17 at 15:46
  • You can try `printf "\0"` or `printf "a\b"` and see if that helps. This will not add unnecessary information – Tarun Lalwani Nov 27 '17 at 16:39
  • @TarunLalwani What information will that display? –  Nov 27 '17 at 19:14
  • Probably nothing but there will be bytes to read I guess so it might do both the tricks. No output and CI also may not timeout – Tarun Lalwani Nov 27 '17 at 19:17
  • @TarunLalwani And what about the `-S .tmp` option? Good idea though –  Nov 29 '17 at 19:48
  • @TarunLalwani Can you add this as an answer? I want to award you the bounty –  Dec 02 '17 at 12:21

1 Answers1

0

Why not launch a function in background which just prints dummy values like uploading, please wait and then sleeps for few seconds and do it again. Outside the loop you can kill that background job

If you don't want any output

printf "\0" 

or

printf "a\b"
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265