LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   cURL recursive FTP upload (https://www.linuxquestions.org/questions/programming-9/curl-recursive-ftp-upload-799375/)

eiland 04-01-2010 09:05 AM

cURL recursive FTP upload
 
Hi,

I work on two hosts, [1] with online ftp access, and [2] without ncftp installed, but with ssh access.

Now I need to recursively upload a folder from [2] to [1]. So I can't use hardfeed - which is for downloading

I think I can use a

find ./orig -exec curl ftp://pinshosting.net

But I'm not so so known with the params of find and curl to get it working recursively. Any hints?

Sergei Steshenko 04-01-2010 09:14 AM

Quote:

Originally Posted by eiland (Post 3920422)
Hi,

I work on two hosts, [1] with online ftp access, and [2] without ncftp installed, but with ssh access.

Now I need to recursively upload a folder from [2] to [1]. So I can't use hardfeed - which is for downloading

I think I can use a

find ./orig -exec curl ftp://pinshosting.net

But I'm not so so known with the params of find and curl to get it working recursively. Any hints?

Have you considered using 'cURL' in conjunction with 'find' - in the latter consider '-exec' command line switch.

eiland 04-01-2010 10:07 AM

YES! That was exactly my question; how to do that....

Sergei Steshenko 04-01-2010 10:08 AM

Quote:

Originally Posted by eiland (Post 3920472)
YES! That was exactly my question; how to do that....

What is the question ? The combination of find + cURL allows cURL to be called for each file separately.

Have you read 'find' manpage ?

eiland 04-01-2010 02:42 PM

so i made a bash script:

Code:

#!/bin/bash
ftp_site=ftp.yoursite.net
username=my_user_name
passwd=my_password
remote=/path/to/remote/folder
folder=$1
cd /path/to/local/folder/$folder
pwd
ftp -in <<EOF
open $ftp_site
user $username $passwd
mkdir $remote/$folder
cd $remote/$folder
mput *
close
bye

and called it with

Code:

find . -type d -exec ./recursive-ftp.sh {} \;
seems to work.


All times are GMT -5. The time now is 06:46 PM.