Operating System - Linux
1825764 Members
2034 Online
109687 Solutions
New Discussion

How transfer direcory using FTP ( and all files inside it )

 
debian111
Regular Advisor

How transfer direcory using FTP ( and all files inside it )

Hi,
I have an question. How transfer direcory using FTP ( and all files inside it )

ftp ???

THanks
12 REPLIES 12
Alexander Chuzhoy
Honored Contributor

Re: How transfer direcory using FTP ( and all files inside it )

Unless you use some sort of script the best way would be to use ftp client.
I'd suggest gftp.
Hope it helps.
debian111
Regular Advisor

Re: How transfer direcory using FTP ( and all files inside it )

Thanks for answer.
I used script, and that script should transfer all files using ftp to windows machine. Script will start at 2:00 using cron deamon. So how do it using script?

Regards
Alexander Chuzhoy
Honored Contributor

Re: How transfer direcory using FTP ( and all files inside it )

I don't know what kind of script do you use, but if you use perl there's a module on cpan called Net::FTP::Recursive. Using this module will make your live easier.
It comes with examples how to achieve what you want.
Hope it helps.
debian111
Regular Advisor

Re: How transfer direcory using FTP ( and all files inside it )

Hi, I am using bash script.
I can transfer one file but I do not know how to transfer a directory and all files inside it.

Thanks for help

Regards
Frank Benke_1
Advisor

Re: How transfer direcory using FTP ( and all files inside it )

Hi,

within the classical ftp command line you can use "prompt no" to prohibit ftp asking you to permit a file when using wildcards. wildcards you are permitted to use when using the "mget" command within ftp. This should apply to the very basic ftp command.

Regards

frank
Vipulinux
Respected Contributor

Re: How transfer direcory using FTP ( and all files inside it )

Hi

Not sure if that is possible but you can tar the directory and then send it across.

If using a script 1st do tar
2nd do ftp

Cheers
debian111
Regular Advisor

Re: How transfer direcory using FTP ( and all files inside it )

I cannot tar it, I have no right priveleges to do it.
I can transfer a directory using GUI gftp, but how do the same using bash shell?

Which commands I must enter in order to make it works?

Anyway thank you very much for your comments.

Regards
Manuel Wolfshant
Trusted Contributor

Re: How transfer direcory using FTP ( and all files inside it )

If I were you, I would look into lftp. It's the very best command line ftp client I have seen in 15 years. You can use it to mirror (the command is ... mirror for download or mirror -R (as in Reverse) for upload). You can also use scripts (the option is "-f" like in lftp -f myscript.lftp) and interact with cron directly from lftp (like in "at hour do something").

Ubfortunately there is no other means to use it efficiently rather then reading the docs.
Robert Walker_8
Valued Contributor

Re: How transfer direcory using FTP ( and all files inside it )

Hi,

You would almost have to pre pass your directory if you only used the basic ftp utility.

(i.e. Get your bash shell to generate an ftp script, including the mkdir commands for ftp, then you would run that script which would include opening ftp server placing username and password if any).

However said tar is probably easier, tar -cvfz /tmp/temp.tar /directory then using ftp - this way you can have ownership, permissions and even soft/hard links if you choose.

Of course "rsync" is probably a better option it can be linked to use SSH (which is better way of doing file transfers - more secure, but thats another story). It will keep two systems directories in sync with each other and is just a command line which can be fed into cron.

Robert.
Manuel Wolfshant
Trusted Contributor

Re: How transfer direcory using FTP ( and all files inside it )

There are a few command line tools for mirroring a folder via FTP: wget (http://wget.sunsite.dk/), lftp (http://wget.sunsite.dk/), curl if you add some scripting around it (http://curl.haxx.se/docs/manpage.html. But, with the risk of repeating myself: so far I haven't found anything as powerful as lftp.
debian111
Regular Advisor

Re: How transfer direcory using FTP ( and all files inside it )

Thanks all,
I made it transfer file by file, and put them in directory at destination. It works for now.
Unfortunately I cannot change anything on server maachine ( it is SYNIX Siemens, high risk machine, and I have no root rights for that). Thank you very much for comments.

Regards


debian111
Regular Advisor

Re: How transfer direcory using FTP ( and all files inside it )

Thanks