Upload.pl

Ever been painstakingly uploading a website by FTP and thought 'there must be an easier way of doing things'? In fact, ever being mirroring anything by FTP across a modem link? This perl script provides a minimal system for mirroring a directory structure by FTP.

Using the script

Easy, just create a directory on the FTP server to upload into and a directory on your local machine to upload from. Put the files you want to mirror in the local directory and run the script - the FTP directory will change into a carbon copy of the local one. When you next run the script, only changes are uploaded - this involves deleting any directories and files that are no longer on the local machine, creating new directories and uploading new and changed files.

Usage

perl upload.pl <source directory> <FTP site> <user name> <password> <FTP directory>

Warning

This script will delete any files on the FTP server that do not exist on the local host. If you are just trying the script out, create an empty directory on the FTP server to upload into. Make sure you type the command line right if there are vital files around! Also note that the behaviour in the presence of symlinks (on the FTP server or the local host) is currently undefined.

Note that the script uses time and size to detect changes, so you may have problems uploading to an ftp server in a different time zone to you, or if your or the ftp server's clock is set incorrectly.

Getting the script

It's here. You will also need the full version of libnet (most perl installations seem to only include some of the functionality). Get it from CPAN or here.