7. RCP: Copying Files

Introduction

The Remote Copy Program (RCP) is a command you can use to copy files between your local OpenVMS host and a remote host.

Use the RCP command to copy remote files. You can copy files:

·         From a remote host to your host

·         From your host to a remote host

·         From one remote host to another remote host (a "third-party" copy)

Before you use RCP, your system manager must install and enable the shell service during TCPware R Services configuration.

Also, make sure your host or username is registered in the remote system's ~/.rhosts (if UNIX) or SYS$LOGIN:.RHOSTS file (if OpenVMS).

If you need to preserve case for any of the command elements, enclose each in quotes, since RSH lowercases unquoted text strings. Include a pair of quotes for each redirection of the command. If you are redirecting a command through one remote host to have it executed on a third, each host in turn strips off a pair of quotes after interpreting the command. In this case, you may need three pairs of quotes around the command element to preserve case.

 

 

 

 


 

RCP

Copies files between the local and remote host, or between two remote systems.

 

Format

RCP source destination

 

Parameters

 

source

Source host and pathname information, in the general format host:filespec

·         host is the remote host name followed by a colon (:).

·         filespec is different for UNIX and OpenVMS systems:

o   For UNIX system source hosts, use the absolute pathname (such as /home/user/file.txt) or the one relative to the user's home directory (file.txt).

o   For OpenVMS source hosts, use the format [dir]file.typ or file.typ, which assumes the current directory.

If you include a username or device, use the following format:

"username@host:device:filespec"

If you include a username and want to copy from a remote host, the remote host must include your host (and username) in its host equivalence file. If you do not use the above format, use the /USER, /PASSWORD, and /TRUNCATE qualifiers.

 

Note: Do not use /USER or /PASSWORD when using DECnet syntax for a source or destination. Instead, use:

 

host"username password"::filespec

 

You also cannot use DECnet syntax for both source and destination (as for a remote-to-remote copy) that involves two passwords.

 

 

 

destination

Destination host and pathname information, in the same format as source.

 

Qualifiers

 

/AUTHENTICATION[=auth-type]

Determines the authentication method. If NULL (or you omit the qualifier), uses standard authentication.

 

/LOG

Logs the files copied to or from the local system. The default is not to log. Logging only applies to the first remote host transaction in a third-party copy.

 

/VMS[={MULTINET | TCPWARE}]
/NOVMS

If /VMS is omitted, RCP by default attempts a TCPware style VMS mode transfer. This retains VMS file attributes across copies. Use /VMS=MULTINET to do a transfer involving a MultiNet machine. Use /NOVMS only if you get the error %DCL-W-IVKEYW, unrecognized keyword - check validity and spelling with the RCP command. /NOVMS disables maintaining VMS file attributes during a third-party copy.

 

/PASSWORD=remote-password

Password for the remote account. Use with the /USER qualifier. Do not use with DECnet source or destination syntax.

 

CAUTION! The password is sent across the network as plain text.

 

 

 

/PRESERVE

Preserves the file protection mode and modification date during a copy.

 

/RECURSIVE

Recursively copies each subtree rooted at the directory you specify in the UNIX system filespec. This makes it possible to copy entire UNIX system directories and their files. In OpenVMS, specify [dir...] (with the three trailing dots) in the filespec instead of using /RECURSIVE.

 

/USER=remote-username

User on the remote host. Use only if the remote host's ~/.hosts or .HOSTS file does not include your local host name or username. If necessary, truncate username to the required number of characters using the /TRUNCATE qualifier. Converted to lowercase if not enclosed in quotes. Do not use with DECnet file syntax.

 

/TRUNCATE[=n]

Truncates the username to the specified n number of characters, since some UNIX systems restrict the length of usernames. If you omit n, the default is eight characters.

 

Examples

1. This command copies a remote UNIX system source file in its home directory to a local host file of the same name in the current directory. The copy preserves the source file's protection mode and modification date.

$ rcp /preserve unixhost:src_file []

 

2. This command copies the complete remote UNIX system directory tree ~/src_dir to the local subdirectory DST_DIR, while logging the copy of each file:

$ rcp /recursive/log unixhost:src_dir [.dst_dir...]

 

3. The first of these two commands only copies the .src_dir subdirectory to a UNIX system. The second command copies the whole subtree.

$ rcp /recursive [.src_dir] unixhost:dst_dir
$ rcp [.src_dir...] unixhost:dst_dir

 

4. This command copies the complete local subdirectory tree SRC_DIR to a remote OpenVMS host's destination directory while preserving the directory hierarchy:

$ rcp [src_dir...] vmshost:[dst_dir...]

 

5. This command copies all files under the local SRC_DIR directory to a remote OpenVMS host's destination directory. This does not preserve the copied directory's hierarchy:

$ rcp [src_dir...] vmshost:[dst_dir]

 

6. This command copies all directories and files under the local SRC_DIR directory to a remote OpenVMS host user's login directory on the DKA300: device (use the double quotes):

$ rcp [src_dir...] "vmshost:dka300:[login...]"

 

7. This command copies the local SRC_FILE on device DKA100: to dst_file on a remote host. Double quotes are needed to specify a device name. The /NOVMS qualifier allows RCP to copy compatibly to an OpenVMS host running TCP/IP Services for OpenVMS (UCX).

$ rcp /novms ":dka100:[src_dir]src_file" ucx_host:dst_file

 

8. This command copies the local SRC_FILE to ~some/dst_file if the remote host is a UNIX system, or [some-login-directory]DST_FILE if the remote host is OpenVMS. (RCP truncates the someone username to some.) In this case, the remote host does not have a host equivalence file entry for the local host, requiring /USER and /PASSWORD.

$ rcp /user=someone/pass=password/truncate=4 src_file host:dst_file

 

9. This command copies a file from one remote host to another (a "third-party" copy):

$ rcp remotehost1:file1 remotehost2:file2

 

10. Using the /USER or /PASSWORD qualifier with DECnet syntax is not allowed and returns the error message shown:

$ rcp /user=user1 new.txt flower"user2 password"::new.txt
TCPWARE-E-NOQUAL, /USERNAME qualifier not allowed with DECnet syntax

 

11. Using multiple passwords with DECnet syntax is not allowed and returns the error message shown:

$ rcp tree"user1 pass1"::new.txt flower"user2 pass2"::new.txt
TCPWARE-E-MULTPW, Multiple passwords not supported