Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

rcp - remote file copy

&pagelevel(4)&pagelevel

The rcp can be used to copy files and directories

  • from a local host to a remote host

  • from a remote host to a local host

  • between two remote hosts

You can use this command, for example, when you want to work with files located on a remote host. The rcp command can be used symmetrically by BS2000-POSIX and remote Unix systems.

Format 1 of the command copies a single file from one host to a file on another host.

Format 2 of the rcp command copies multiple files or a directory of another host.

The rcp command can only be used by users with access authorization on the remote host. In other words, the .rhosts file in the HOME directory of the ID on the remote host must have an entry containing the name of the local host or a plus character (+) and the user ID. The user ID must have a standard account number for rlogin access. This standard account number can be assigned using the ADD-USER, MODIFY-USER-ATTRIBUTES or ADD-POSIX-USER command. 

The files /etc/hosts and /etc/hosts.equiv usually used in Unix systems are not used in POSIX. The assignment of host names to IP addresses is handled via BCAM or DNS.


Syntax


Format 1: rcp[  -p][  -b] file1 file2
Format 2: rcp[  -pr][  -b] file ... dir


Copy individual files
Format 1: rcp[-p][-b] file1 file2


No option specified

The modification and access times of each copy are set to the current time. The access permissions are set in accordance with umask.

-p

Every copy receives the same modification and access times and the same access permissions as the original file.

-b

The file is transferred in binary mode.

file1

is the file to be copied. This file may be stored on the local or remote host.

If the file is stored on the local host, it may be specified with path, where path is the pathname of file1. If path is not an absolute pathname, it is interpreted as a relative path to the current directory.

If the file is stored on a remote host, file1 must be specified in the following format:

login@remote_host:path or

remote_host:path or

login@remote_host.domain:path

remote_host

is the name of the remote host or its IP address in IPv4 or IPv6 dot notation:


IPv4n.n.n.nn = 0..255 (decimal)
IPv6x:x:x:x:x:x:x:xx = 0..FFFF (hexadecimal)


The alternative presentation methods described in RFC 2373 are permissible for IPv6 dot notation.
If for the name of the remote host its address is specified in IPv6 dot notation, this must be enclosed in square brackets, e.g.:

rcp test hansi@[::ffff:AC19:7D37]:hansi_test

Otherwise the first colon in the IPv6 address would be incorrectly interpreted as a separator between the host name and the path name.

login

is the user ID on the remote host.

path

is the pathname of file1.

domain

is the name of the DNS domain to which the remote host belongs.

Pathnames may include the usual metacharacters (e.g. *, ?) for constructing file names. These metacharacters are evaluated on the local host. path must not contain a colon ":", and the string for login@remote_host must not include a slash "/".

file2

is the file to which the source file is to be copied. This file may be placed on the local or remote host. If the file already exists, it will be overwritten.

The format is the same as for file1.

Copy multiple files or directories
Format 2: rcp[  -pr][  -b] file ... dir


No option specified

The modification and access times of each copy are set to the current time. The access permissions are set in accordance with umask.

-p

Every copy receives the same modification and access times and the same access permissions as the original file.

-r

All subdirectories of dir are copied recursively. In this case, file must be a directory.

-b

The file is transferred in binary mode.

file

may be

  • a file,

  • multiple files, or

  • a directory (with -r)

on the local or remote host.

The following format applies on the local host:

filename ...

or

directory

filename is the respective name or pathname of one or more files.
directory is the respective name or pathname of the directory.

If file is located on the remote host, the following applies:

login@remote_host:path or

remote_host:path or

login@remote_host.domain:path

remote_host

is the name of the remote host.

login

is the user ID on the remote host.

path

is the pathname of file1.

domain

is the name of the DNS domain to which the remote host belongs.

Pathnames may include the usual metacharacters (e.g. *, ?) for constructing file names. These metacharacters are evaluated on the local host.

Example

$ rcp remote_host:path1/* path2/dir

copies all files that match the first pathname into the specified directory.

dir

is the directory to which the files or directories are to be copied. This directory may be located on the local or remote host. Files of the same name, if any, are overwritten.

The format for dir on the remote host is:

directory

The format for dir on the remote host is:

login@remote_host:directory

or

login@remote_host.domain:directory

Error

remote_host: unknown host

The host is not known to BCAM or only known under another alias.


remote_host: Connection timed out
No acknowledgment was received from the remote host within a specified period.

File

$HOME/.rhosts

List of host names and user IDs that can log on to them under those IDs.

Example 1

The POSIX user john wants to copy the file test from his current directory to the user john on the remote host rainbow. The copied file is to be named john_test on the remote host rainbow. The required access permissions for the copy operation are present.

$ rcp test john@rainbow:john_test

Example 2

The POSIX user john copies the directories test and practice from the login name john on the host rainbow to the POSIX directory /home/john/rainbow_copy.

$ rcp -r john@rainbow:test john@rainbow:practice /home/john/rainbow_copy

See also

rsh