ECN No Name Newsletter: September, 1991

The ECN No Name Newsletter is no longer being published. This is an archived issue.

[previous article] [next article]

Tranferring Files Between Machines

Cyrus Dadgar

In the perfect world of computing, machines never crash, users have unlimited disc quota, and all the system tools are readily available. Unfortunately, we live in a far less than perfect world. At any given time, it is likely that one or more machines are down, disc quota is a highly valued commodity, and some programs (like compilers) are only on certain machines.

To solve these problems, users are given multiple accounts. However, this solution isn't without problems of its own. A common hardship among users is transferring files from one machine to another. Luckily, there are many methods to accomplish this task. Two programs that are widely used are ftp and rcp.

----------
FTP--Transferring files between different individuals
----------

The ftp command stands for `file transfer program'. It is more cumbersome to use than rcp, but requires less initial set-up. As an example, lets say I wanted to copy the file `foobar' on the ei machine to the en machine. I would first log onto one of the machines and connect to the other via the ftp command. The ftp program would then prompt me for my login and password on the remote machine. After connection has been established, it is a simple matter of using the "get" and "put" commands to transfer the proper files. The "quit" command will then terminate the ftp session. An ftp session follows:

%    ftp en
Connected to en.ecn.purdue.edu.
220 en.ecn.purdue.edu FTP server ready.
Name (en:siphon):    siphon
331 Password required for siphon.
Password:     ***type password here ***
230 User siphon logged in.
ftp>    get foobar
200 PORT command successful.
150 Opening ASCII mode connection for foobar (5 bytes).
226 Transfer complete.
local: foobar remote: foobar
6 bytes received in 0.033 seconds (0.18 Kbytes/s)
ftp>    quit
221 Goodbye.
%
---------
RCP--Transferring files between accounts owned by one person
---------

The rcp command stands for `remote file copy'. As stated before, it can require some initial setup. Machines that are listed in the file "/etc/hosts.equiv" allow you to copy files remotely without being in the remote machines rhosts file. Otherwise you will need to create a file called .rhosts on the remote machine and add your accounts to it. Each line of the .rhosts file should be of the form: "machine login". For example, the line "orchestra.ecn.purdue.edu siphon" is in my .rhosts file, and allows the orchestra machine to remotely copy files from my other accounts. Care should be taken to make sure the .rhosts" file cannot be modified by others. The command

                      "chmod 700 .rhosts"

will make sure that others are not allowed to edit it.

The format of the rcp command is "rcp (from) (to)" ; "from" specifies the source, and "to" specifies the destination. Either can be of the form "host:path" ; "host" specifies a machine, and "path" specifies the files to copy.

The rcp command will use the present working directory (pwd) and the user's home directory on the remote machine as reference points. For example, if I was logged on the ei machine and issued the "rcp foobar en:. " . The net results would be the file "foobar" that is in the present working directory in the ei machine to be copied to the users home directory on the en machine.

Recursive copying permits the entire contents of a directory to be transferred. The "-r" flag is given after the command, rcp if the source file is a directory. will copy entire directories if the source file is a directory. If this flag is specified, the source file and the destination must both be a directories. For example, the command "rcp -r bin en:. " would copy a directory called "bin" to the en machine.

Third party copying is when neither the source or destination files are on the current machine. For example, if I was logged on the en machine, the command "rcp ei:foobar ed:." would copy the file "foobar" on the ei machine to the ed machine.

The rcp command will not operate correctly if there are any output generating commands in a .login, .profile, or .cshrc file on the remote host. For example, if the remote host's .cshrc file has an echo command, the connection will fail. A more dubious error is to place the biff command in your .cshrc file. This to will cause rcp to fail.


webmaster@ecn.purdue.edu
Last modified: Thursday, 23-Oct-97 18:10:12 EST

[HTML Check] HTML