FTP in Shell Script

Tony Hammitt thammitt at kc.rr.com
Tue Jul 25 16:30:50 CDT 2000


Also consider rsync, which is designed to do what you are doing.  I hear
that it can be used over a secure link, but I haven't tried it.

When you get done, would you consider posting your script?  It could save
someone else a lot of work.

OK, so I spent a few minutes looking into rsync over ssh.  It's pretty
simple.  Set up rsync and ssh on both boxes, start sshd, use:

rsync -Cavz -e ssh <otherhost>:/home/<path>/ <localpath>/

Works like a charm.  Can be put in a crontab easily.  For playing around
I'd recommend using "-Cazvn" since the 'n' prevents it from actually
doing anything until you know it works.

No sweat...

	Tony

Drew_Rohde at kcmo.org wrote:
> 
> I'm writing a shell script (korn) to find any files in a directory tree
> that are new or changed and ftp them to another system in the same
> directory structure.  I have been successful finding the files with -newer
> comparing to a time stamp file that I touch every time the script runs, but
> am getting stumped on automating the login for the ftp.
> I chose shell over perl because I thought it would be easier to learn,
> since I haven't done either very much.
> I remember reading (at some time many brain cells ago) about macros for
> ftp, but there were security concerns, and this will be ftping through a
> firewall.  Since I need to get this done this afternoon, I just need
> something simple that will work for the short term.  Then I will look into
> doing it more securely with more bells and whistles, like making sure the
> parent directory exists first and creating it if not, and replicating
> deletions to the destination.  Current assumption is that the parent
> directories exist and we don't care about deletions.
> 
> Any suggestions would be greatly appreciated.
> Drew
> 




More information about the Kclug mailing list