8

Basically, I'm trying to do this:

some_other_program | curl ftp://username:[email protected]/file.txt

As a test case to see if I can get it working, I'm trying it with cat like so:

cat test.txt | curl -d @- ftp://admin:[email protected]/file.txt

Notice, I tried the -d @- thing, but it doesn't work. How do I do this?

This question is similar, but that one is about HTTP, my question is about FTP.

101010
  • 713
  • 1
  • 12
  • 18
  • Possible duplicate of [How to send a file to an FTP server that doesn't properly terminate the connection on success?](http://unix.stackexchange.com/questions/341233/how-to-send-a-file-to-an-ftp-server-that-doesnt-properly-terminate-the-connecti) – DopeGhoti Jan 30 '17 at 16:51
  • 1
    Use `-T -` for ftp instead of `-d @-` which is just for http. – meuh Jan 30 '17 at 17:24
  • That works thanks! Make it the answer and I'll mark it (why don't people just do that?) – 101010 Jan 30 '17 at 17:26

1 Answers1

8

curl's -T accepts - to read from stdin.

The command reads like:

cat test.txt | curl -T - ftp://admin:[email protected]/file.txt

Here's an example used to upload a file to Vimeo directly:

gsutil cp gs://my-bucket/video.mp4 - | curl -T - ftp://user:[email protected]/video.mp4
bahamat
  • 38,658
  • 4
  • 70
  • 103
urish
  • 181
  • 1
  • 5