0

I am trying to write a script that will help me upload a directory to a FTP location.

The directory structure looks like so:

MasterDirectory/
    file1.jpg
    file2.jpg
    ChildDirectory/
        childFile.jpg

Ideally, I want to write a shell script that does the following:

  • cd MasterDirectory/
  • iterate through all contents
  • if there is a file, upload that file with curl -T filename and FTP
  • if there is a directory, upload that directory and all of its contents, including any subdirectories

I am able to upload a single file with the command curl -T filename.jpg ftp://ftp.server.com --user username:password but past that, I am a bit lost. Can anyone show me what kind of script I would write to accomplish this?

I want this script to run in the after-success node of a Travis CI job. I am not married to the idea of using a shell script, but this feels like the best way to do this. If anyone has a better idea for doing this with Travis CI, I am open to suggestion!

Thank you so much in advance for any help you can provide!!!

dokun1
  • 2,120
  • 19
  • 37

1 Answers1

2

The outcome of this use case is much like a previous question . If you're ok with running a single line of code instead of writing a script, you should be able to accomplish the goal using:

find MasterDirectory -type f -exec curl --user username:password --ftp-create-dirs -T {} ftp://ftp.server.com/{} \;

timro
  • 36
  • 1
  • 6