1

I am struggling with uploading a file to an SFTP from a URL. All steps work independently but when I combine them they seem to be split into two separate tasks, downloading the file and then connecting to the SFTP. No errors are thrown at any point, but files are not transferring. Is there any way to make this work?

Downloading works following redirects

$ curl -L "https://docs.google.com" -o test.csv 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   452    0   452    0     0   1155      0 --:--:-- --:--:-- --:--:--  1158
100  1302    0  1302    0     0   1496      0 --:--:-- --:--:-- --:--:--  4840 

Upload to SFTP works

$ curl -u user:password -T test.csv sftp://sub.domain.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1302    0     0  100  1302      0  13557 --:--:-- --:--:-- --:--:-- 13705
100  1302    0     0  100  1302      0  13554 --:--:-- --:--:-- --:--:-- 13554

Mixing doesn't place the file in the SFTP

$ curl -L "https://docs.google.com" -o nextCurlTest.csv -u user:password sftp://sub.domain.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   452    0   452    0     0   1442      0 --:--:-- --:--:-- --:--:--  1444
100  1302    0  1302    0     0   1873      0 --:--:-- --:--:-- --:--:--  1873
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

Seeing as it seems to be opening the SFTP separately I attempted adding it inline as a regular SFTP transfer, but that didn't work either.

$  curl -L "https://docs.google.com" -o Test2.csv -u user:password -T Test2.csv sftp://sub.domain.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1754    0   452  100  1302   1414   4075 --:--:-- --:--:-- --:--:--  5515
100  4395    0  3093  100  1302   4458   1876 --:--:-- --:--:-- --:--:--  6334
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4
  • Is there some reason you can't just use two commands? (Put && between them if you're using a shell or shell interpreter.) AFAIK you can't do multiple transfers with different options, writing and reading the same file, with one curl command, but I could be wrong. Commented Sep 13, 2022 at 20:41
  • That makes sense but adding && throws an error. bash: -u: command not found Commented Sep 14, 2022 at 18:03
  • You do have curl again after the &&, don't you? I don't see what else would cause that error. Are you just writing the commands at the command line, or launching them some other way? Since those aren't the real urls it's kind of hard for me to test. Commented Sep 14, 2022 at 18:07
  • Oh, I forgot to add the curl command. My bad. It worked after that. Thanks for the assistance! Commented Sep 14, 2022 at 18:29

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.