Usage: transfer <full|incr> [info_file]
The first command-line argument to "transfer" is required. It must be either the string "full" or the string "incr". This argument is case-insensitive.
The second argument is optional and specifies the path to an information file for the current transfer. See below for the content and syntax of an information file.
Back to Table of Contents.
The perl script "transfer" was written to facilitate easy transfer of entire directory trees via FTP and to allow the user to exclude certain files or directories from the transfer. The script logs each transfer in a user-specified log file and indicates whether each transfer was successful or failed.
The script supports two type of transfers, a "full" transfer and an "incr" or incremental transfer. In a "full" transfer, all of the files that are not on the list of files to be excluded are transferred. In an "incr" or incremental transfer only files more recently modified than the log file that are not on the list of files to be excluded are transferred.
The script takes two command line arguments. The first argument is required and specifies the transfer mode as "full" or "incr". This argument is case-insensitive. The second argument is optional and specifies a file containing information such as the name of the remote host which is needed for making the transfer. The user is prompted for whatever required information that is not found in the information file. The format of an information file is described below.
If a second command line argument is not provided and the HOME environment variable is set, the script will check the file $HOME/.transferrc for information. As described above, the user is prompted for any needed information that it does not find in a file. This allows a user to keep a default information file so that the script will only prompt for information that changes with each transfer.
The script can be used interactively or automatically via a facility such as "at" or "cron". In this case, an information file is needed since the HOME environment variable is usually not set. The file must provide all needed information since the script will not be able to query the user.
The necessary information includes the username and password for the remote account. Therefore, the information file should only be readable by the user. This means that you should execute the following command for whatever information file you intend to use:
where "info_file" is the name of your information file.
See the Examples section below for various scenarios in which one might use "transfer".
Back to Table of Contents.
"Transfer" will run on any system connected to the Internet that has Perl 5 with the Net:FTP module installed. The remote system must be running an FTP server that can respond to the FTP requests. Both systems must be connected to the Internet before starting the transfer. This means that, if you need to dial up, you must do so before running "transfer".
Either host can be running any operating system that can satisfy these requirements. This means that either host can be a Windows box or a Macintosh with the appropriate software. Perl is freely available for either and free FTP servers are also available on the Internet.
Back to Table of Contents.
"Transfer" requires the following information to make a transfer.
Information | Description |
---|---|
host | Enough of the fully-qualified domain name so that the local host can contact the remote host. |
username | Account name on the remote host. |
password | Password for the remote account. |
log file | Full path to the log file. The log file resides on the local host. |
local root | This is the local directory where all of the files and directories that are to be transferred reside. The remote directory structure under the remote root will mirror the local directory structure under the local root for the files and directories that are transferred. |
remote root | This is the remote directory that all of the files and directories will be transferred into. The remote directory structure under the remote root will mirror the directory structure under the local root for the files and directories that are transferred. |
list | This is the list of full local paths to the files and directories that will be transferred. |
Required information is gathered from an information file or by prompting the user. The user is prompted for any required information not supplied in an information file.
The following information is optional.
Information | Description |
---|---|
exclusion list | This is the list of full local paths to the files and directories that you wish to exclude from being transferred. |
connect script | The path to a script which establishes a network connection. |
disconnect script | The path to a script which terminates the network connection. |
Optional information may be supplied in an information file. If a file is not provided, the script will ask the user if they wish to supply the optional information. If a file is provided but any optional information is not specified in the file, then the script assumes that the user does not want to provide the optional information and does not prompt the user.
An information file may contain comments which consist of anything following the character "#". Comments may occupy entire lines or may be at the end of lines. Information files may contain blank lines and the information in the file may have an arbitrary amount of white space surrounding it. White space is strings of characters such as spaces, tabs, line feeds, or returns.
Each information line in an information file consists of a key word followed by an equal sign followed by a value, terminated by a semi-colon. This means that there cannot be a semi-colon in the password for the remote account. Passwords also may not contain white spaces. Information lines may span several lines in the file just like lines of C code.
Here is an example information file.
# Comment at the beginning of the information file. # This is an example information file. connect = /sbin/connect; disconnect = /sbin/disconnect > /dev/null; host = dante.u.washington.edu; # As good a place as any. username = silver_surfer; # Only an example. password = way2late; # Only an example. logfile = /home/silver_surfer/log/transfer_log; local_root = /home/silver_surfer; remote_root = .; # How to specify the remote home directory as remote root. list = /home/silver_surfer/dissertation, /home/silver_surfer/programs, /home/silver_surfer/important_mail_mesg; exclude = /home/silver_surfer/programs/huge_data_file, /home/silver_surfer/programs/pictures, /home/silver_surfer/programs/tmp; # This comment marks the end of the information file.
This example shows all of the key words used by "transfer". The key words are "connect", "disconnect", "host", "username", "password", "logfile", "local_root", "remote_root", "list", and "exclude". The example also shows how one can use comments, white space, and blank lines in an information file. There can be white space between the values and the terminating semi-colon too.
The example illustrates two important features of an information file. First, notice that the list of files and directories to be transferred and the list of files and directories to be excluded from transfer are comma-separated lists. In the example, dissertation, programs, programs/pictures, and programs/tmp are directories and important_mail_mesg and huge_data_file are files. This also shows a few types of files and directories that you may not want to transfer. The directory programs/tmp probably doesn't contain anything worth keeping for long and you may not have enough space on the remote host to store very large files.
The second important feature of the above information file is that the remote root is specified as ".". "." represents the current directory. This is the way that you specify the home directory for the remote account as the remote root. A blank value WILL NOT WORK and will result in unpredictable results.
An information file can specify any subset of the above information. As mentioned before, "transfer" will prompt the user for any information that is not provided by an information file.
Back to Table of Contents.
I run "transfer" with a connect script to dial school and establish a ppp connection and a disconnect script to terminate the ppp connection and hang up the phone once the transfers are complete. It is important to keep at least a couple of copies of your most important work in different places in case the unforseen happens. "Transfer" has made this very easy.
Assuming that you have an FTP server running on your home computer, it is easy to accomplish this task using "transfer". First dial into the ACC and start your FTP server software, if necessary. Then open a window on one of the Amath machines. You will run "transfer" on the Amath machine so the Amath machine will be the local host and your computer will be the remote host.
At this point, either set up an information file or collect the relevant information for when "transfer" prompts you for information. Probably the most mysterious part of this is determining the host name to use since the ACC uses DHCP and assigns you a different host name (and IP address) every time you dial up. You can find this information by executing the command "who -mM" in the Amath window. Your host name will have the form cs???-??.classification.washington.edu.
Once you have the information, simply run "transfer" to copy your files and directories to your home system.
Back to Table of Contents.
System produces error such as "cannot find file" when you try to execute "transfer".
Suggestion:
If the system gives an error like this, it's possible that the first line of "transfer" doesn't specify the correct path to perl for your system. Use the command "which perl" or, on some systems, "whence perl" to find the correct path and verify that the first line is correct. If the line is not correct, modify the line appropriately.
This problem may also occur if "transfer" is not in your PATH. For example, if the current directory "." is not in your PATH and you are trying to execute "transfer" from your current directory, you will need to precede transfer with "./" on the command line, as in the example
./transfer incr info_file
The current directory "." is not in the default PATH on some systems such as Redhat Linux, for example, since having "." in your PATH is a security hazard.
Not all files on the exclude list are excluded.
Suggestion:
Make sure that all entries in the exclude list are separated by commas.
Cannot use the home directory of the remote account as the remote root from an information file. Suggestion:
If you want to use the home directory of the remote account as the remote root using an information file, you must specify the remote root as
If the value for remote_root is blank in an information file, "transfer" will not read the information fields properly. However, a blank value for the remote root should work fine when entered interactively.
Back to Table of Contents.
Documentation for "Transfer", a perl script for recursively FTPing files and directories to remote hosts.
© 1998 Mark A. Martin, mark@mark-a-martin.usLast modified Sat Jul 18 09:26:01 1998