Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp of an entire directory 4

Status
Not open for further replies.

westd

Programmer
Jul 12, 2001
1
0
0
GB
Hi there,

Can anyone tell me how to modify the script in the FAQ section to ftp the contents of an entire directory to another server instead of just one file?

Thanks,
Dave
 
Yep,

I don't know about that faq script but the ftp commands are as follows (and these can be used in a script if you know how to make a here-to construct):

mput *
mget *

mput is multiple-put. mget is multi-get. You can give it wildcards and it will grab them all. One thing though, it will prompt you for a yes/no for each filename. To turn off the prompting so it does them all without pause use:

prompt

That toggles the prompting. You might also want to use the ftp command:

hash

This gives hash symbols (#) as it transfers so you know the program is not asleep and you have some idea of how far it's gone. Good for big jobs. Turn if off if it's a background job writing to a log file.

prompt and hash are "toggle" commands. By that I mean entering it once turns it on, entering again turns it off, etc.

Hope that helps
 
Even better, and all in one command...


wget -r ftp://username:password@ftp.host.org/path/to/directory/* /tmp

that says loginto ftp.host.org with
username: username
password: password

and grab everything in /path/to/directory/ and below
and place it in the /tmp directory on the local machine...

learn wget it will be your best friend :)

-John
 
Could also try embedding a tar command in the put statement:

put "|tar cf - ./dirname" dirname.tar

I don't believe this to be documented anywhere...one of my previous workmates showed me this one :)

--Avardan
 
#CRON ftp Script
#
cd /path/to/directory
ftp -inv <<!
open 192.168.1.23 #Ip address of remote host
user login password
bin
mget * #mget * get all files in directory
quit


-Danny






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top