Yaniv Ben-Malka
Yaniv Ben-Malka

Reputation: 47

Copy all files from a directory to FTP with cURL

I try to copy all files from a directory to FTP using curl, with the following command:

find Users/a/Desktop/Test/ -type f -exec curl -u ftpuser:ftppass --ftp-create-dirs -T {} ftp://ftps.pmc.com/Test/{} \;

And keep getting the following error:

FIND: Parameter format not correct

Alternatively, I try this command:

find Users/a/Desktop/Test/ -name '*' -type f -exec curl -u ftpuser:ftppass -T {} ftp://ftps.pmc.com/Test/ \;

And get this error:

File not found - '*'

Please share your suggestions on how to syntax the command correctly , or other suggestions on how to accomplish the need of copying all files in a directory using curl.

Thanks

Upvotes: 0

Views: 2653

Answers (1)

Trupti J
Trupti J

Reputation: 522

Since you are on Windows OS, you cannot use Find and curl commands mentioned here to upload your files to FTP. To Upload files to FTP server using windows command prompt, you can follow the below steps:

  • Open Command Prompt.
  • Type Command -> ftp ftps.pmc.com
  • You will now be connected to ftp. It will say Connected to ftps.pmc.com.
  • You will be asked to enter username and password. Please enter it correctly.
  • First enter username, once that username available, you will be asked to enter password.
  • Password will not display anything on the screen while typing, you need to make sure that you do not press backspace or any other key while typing password as it will directly read the password from your keyboard inputs.
  • Once you are successfully connected to it, you need to move to your required directory on ftp server using cd command. e.g., cd test
  • Then, to copy files from your local machine you need to enter command -> lcd Users/a/Desktop/Test/
  • Then put command will be used to upload your files to the ftp server. put *.txt will upload all your text files to the current folder on ftp. mput will upload all files from Users/a/Desktop/Test/ local folder to the current folder on ftp one by one.
  • mput command can also be used to upload the whole folder.
  • Please note that command and files names used here in the command prompt will be case sensitive.

So the list of command will be

 1. ftp ftps.pmc.com 
 2. ftpuser
 3. ftppass
 4. cd test
 5. lcd Users/a/Desktop/Test/
 6. put *.txt (OR mput)

Upvotes: 2

Related Questions