Using Internet Services

28 Chapter4
Transferring Files with rcp
Using rcp
Using rcp
You can use rcp to copy one or more files or directories from the local
host to a remote host, as in the following example:
rcp /tmp/memo1 /tmp/memo2 basil:/home/basil/roger
This example copies /tmp/memo1 and /tmp/memo2 from the local host to
user roger’s home directory on host basil. The last path on the
command line is taken as the destination path, and all paths beforeit are
copied to the destination.
You can use rcp to copy one or more remote files or directories to the
local host. With the -r (recursive) option, you can use rcp to copy the
contents of a directory and all its subdirectories, as in the following
example:
rcp -r sage:/home/sage/gwen /home/dill/gwen
This example copies the contents of user gwen’s home directory from host
sage to the directory /home/dill/gwen on the local host.
If you do not specify a full path name, the path name is interpreted
relative to your home directory, as in the following example:
rcp memo* *mail sage:june_mail
This example copies all files whose names begin with memo and all files
whose names end with mail from the user’s local home directory to the
directory june_mail in the user’s home directory on host sage.
NOTE Any output generated by commands in a .login, .profile, or .cshrc
file on the remote host can cause rcp errors.
CAUTION Do not attempt to copy a file over itself, as in the following example:
rcp /home/cheryl/.profile /home/cheryl/.profile
This can corrupt the file’s contents.