rcp

This connectivity command copies files between a Window NT computer and a computer running rshd, the remote shell server service or daemon. (A service is called a daemon in UNIX.) The rcp command can also be used for third-party transfer to copy files between two computers running rshd when the command is issued from a Windows NT-based computer. The rshd server service (daemon) is available on UNIX computers, but not on a Windows NT-based computer. The Windows NT-based computer can only participate as the computer from which the commands are issued. The remote computers must also support the rcp utility in addition to running rshd.

Syntax

rcp [-a | -b] [-h] [-r] source1 source2 ... sourceN destination

Parameters

-a

Specifies ASCII transfer mode. This mode converts the carriage return/linefeed characters to carriage returns on outgoing files, and linefeed characters to carriage return/linefeeds for incoming files. This is the default transfer mode.

-b

Specifies binary image transfer mode. No carriage return/linefeed conversion is performed.

-h

Transfers source files marked with the hidden attribute on the Windows NT-based computer. Without this option, specifying a hidden file on the rcp command line has the same effect as if the file did not exist.

-r

Recursively copies the contents of all subdirectories of the source to the destination. Both the source and destination must be directories.

source and destination

Must be of the form [host[.user]:]filename. If the [host[.user]:] portion is omitted, the host is assumed to be the local computer. If the user portion is omitted, the currently logged-on Windows NT user name is used. If a fully qualified host name is used, which contains the period (.) separators, then the [.user] must be included. Otherwise, the last part of the host name is interpreted as the user name. If multiple source files are specified, the destination must be a directory.

If the filename does not begin with a forward slash ( / ) for UNIX computers or a backward slash ( \ ) for Windows NT-based computers, it is assumed to be relative to the current working directory. Under Windows NT, this is the directory from which the command is issued. On the remote computer, it is the logon directory for the remote user. A period (.) means the current directory. Use the escape characters ( \ , ", or ') in remote paths to use wildcard characters on the remote host.

Notes

Remote Privileges

The rcp command does not prompt for passwords; the current or specified user-name must exist on the remote host and enable remote command execution via rcp.

The .rhosts File

The .rhosts file specifies which remote computer or users can assess a local account using rsh or rcp. This file (or a HOSTS equivalent) is required on the remote computer for access to a remote computer using these commands. Rsh and rcp both transmit the local user name to the remote computer. The remote computer uses this name plus the IP address (usually resolved to a host name) or the requesting computer to determine whether access is granted. There is no provision for specifying a password to access an account using these commands.

If the user is logged on to a Windows NT Server domain, the domain controller must be available to resolve the currently logged-on name, because the logged-on name is not cached on the local computer. Because the user name is required as part of the rsh protocol, the command fails if the user name cannot be obtained.

The .rhosts file is a text file where each line is an entry. An entry consists of the local host name, the local user name, and any comments about the entry. Each entry is separated by a tab or space, and comments begin with a hash mark (#),for example:


computer5 marie #This computer is in room 31A

The .rhosts file must be in the user's home directory on the remote computer. (Normally a DNS name server is used instead of the .rhosts file.)

Additionally, have your host name added to the remote computer's /Etc/Hosts file. This enables the remote computer to authenticate remote requests for your computer using the Microsoft TCP/IP utilities.

For more information about a remote computer's specific implementation of the .rhosts file, see the remote computer's documentation

Specifying Hosts

Use the host.user variables to use a user name other than the current user name. If host.user is specified with source, the .rhosts file on the remote host must contain an entry for user.

If a host name is supplied as a full domain name containing periods, a user name must be appended to the host name. This prevents the last element of the domain name from being interpreted as a user name. For example,


rcp domain-name1.user:johnm domain-name2.user:richr

Remote Processing

Remote processing is performed by a command run from the user's logon shell on most UNIX computers. The user's .profile or .cshrc is executed before parsing filenames, and exported shell variables can be used (using the escape characters or quotation marks) in remote filenames.

Copying Files

If you attempt to copy a number of files to a file rather than a directory, only the last file is copied. Also, the rcp command cannot copy a file onto itself.

Examples

These examples show syntax for some common uses of rcp.

To copy a local file to the logon directory of a remote computer:


rcp filename remotecomputer:

To copy a local file to an existing directory and a new filename on a remote computer:


rcp filename remotecomputer:/directory/newfilename

To copy multiple local files to a subdirectory of a remote logon directory:


rcp file1 file2 file3 remotecomputer:subdirectory/filesdirectory

To copy from a remote source to the current directory of the local computer:


rcp remotecomputer:filename

To copy from multiple files from multiple remote sources to a remote destination with different user names:


rcp remote1.user1:file1 remote2.user2:file2 remotedest.destuser:directory

To copy from a remote computer using an IP address to a local computer (where the user name is mandatory because a period is used in the remote host name):


rcp 11.101.12.1.user:filename filename