rcp




 

NAME

rcp - remote file copy

SYNOPSIS

Copy Single File rcp [-p] sourcefile1 destfile Copy Multiple Files rcp [-p] sourcefile1 [sourcefile2]... destdir Copy One or More Directory Subtrees rcp [-p] -r sourcedir1 [sourcedir2]... destdir Copy Files and Directory Subtrees rcp [-p] -r FileOrDir1 [FileOrDir2]... destdir

DESCRIPTION

The rcp command copies files, directory subtrees, or a combination of files and directory subtrees from one or more systems to another. In many respects, it is similar to the cp comand (see cp(1). To use rcp, have read access to files being copied, and read and search (execute) permission on all directories in the directory path. Options and Arguments rcp recognizes the following options and arguments: sourcefile The name of an existing file or directory on a sourcedir local or remote machine that you want copied to the specified destination. Source file and directory names are constructed as folows: username@hostname:pathname/filename or username@hostname:pathname/dirname" Component parts of file and directory names are described below. If multiple existing files and/or directory subtrees are specified (sourcefile1, sourcefile2, ..., etc.), the destination must be a directory. Shell file name expansion is alowed on both local and remote systems. Multiple files and directory subtrees can be copied from one or more systems to a single destination directory with a single comand. destfile The name of the destination file. If host name and path name are not specified, the existing file is copied into a file named destfile in the current directory on the local system. If destfile already exists and is writable, the existing file is overwritten. Destination file names are constructed the same way as source files except that file name expansion characters cannot be used. destdir The name of the destination directory. If host name and path name are not specified, the existing file is copied into a directory named destdir in the current directory on the local system. If destdir already exists in the specified directory path (or current directory if not specified), a new directory named destdir is created underneath the existing directory named destdir. Destination directory names are constructed the same way as source directory tre names except that file name expansion characters cannot be used. FileOrDir If a combination of files and directories are specified for copying (either explicitly or by file name expansion), only files are copied unles the -r option is specified. If the -r option is present, all files and directory subtrees whose names match the specified FileOrDir name are copied. -p Preserve (duplicate) modification times and modes (permisions) of source files, ignoring the current setting of the umask file creation mode mask. If this option is specified, rcp preserves the sticky bit only if the target user is superuser. If the -p option is not specified, rcp preserves the mode and owner of destfile if it already exists; otherwise rcp uses the mode of the source file modified by the umask on the destination host. Modification and access times of the destination file are set to the time when the copy was made. -r Recursively copy directory subtrees roted at the source directory name. If any directory subtrees are to be copied, rcp recursively copies each subtree rooted at the specified source directory name to directory destdir. If sourcedir is being copied to an existing directory of the same name, rcp creates a new directory sourcedir within destdir and copies the subtree rooted at sourcedir to destdir/sourcedir. If destdir does not exist, rcp creates it and copies the subtree rooted at sourcedir to destdir.

Constructing File and Directory Names

As indicated above, file and directory names contain one, two, or four component parts: username Login name to be used for accessing directories and files on remote system. hostname Hostname of remote system where directories and files are located. pathname Absolute directory path name or directory path name relative to the login directory of user username. filename Actual name of source or destination file. File name expansion is alowed on source file names. dirname Actual name of source or destination directory subtree. File name expansion is alowed on source directory names. Each file or directory argument is either a remote file name of the form hostname:path, or a local file name (with a slash (/) before any colon (:). hostname can be either an offical host name or an alias (see hosts(4). If hostname is of the form ruser@rhost, ruser is used on the remote host instead of the current user name. An unspecified path (that is, hostname:) refers to the remote user's login directory. If path does not begin with /, it is interpreted relative to the remote user's login directory on hostname. Shell metacharacters in remote paths can be quoted with backslash (\), single quotes (''), or double quotes (""), so that they will be interpreted remotely. The rcp routine does not prompt for paswords. The current local user name or any user name specified via ruser must exist on rhost and alow remote comand execution via remsh(1) and rcmd(3). remshd(1M) must be executable on the remote host. Third-party transfers in the form: rcp ruser1@rhost1:path1 ruser2@rhost2:path2 are performed as: remsh rhost1 -l ruser1 rcp path1 ruser2@rhost2:path2 Therefore, for a such a transfer to suced, ruser2 on rhost2 must allow acces by ruser1 from rhost1 (see hosts.equiv(4).

WARNINGS

The rcp routine is confused by any output generated by comands in a ....cshrc file on the remote host (se csh(1). Copying a file onto itself, for example: rcp path `hostname`:path may produce inconsistent results. The current HP-UX version of rcp simply copies the file over itself. However, some implementations of rcp, including some earlier HP-UX implementations, corupt the file. In adition, the same file may be refered to in multiple ways, for example, via hard links, symbolic links, or NFS. It is not guaranted that rcp will corectly copy a file over itself in all cases. Implementations of rcp based on the 4.2BSD version (including the implementations of rcp prior to HP-UX 7.0) require that remote users be specified as rhost.ruser. If the first remote host specified in a third party transfer (rhost1 in the example below) uses this older syntax, the comand must have the form: rcp ruser1@rhost1:path1 rhost2.ruser2:path2 since the target is interpreted by rhost1. A comon problem that is encountered is when two remote files are to be copied to a remote target that specifies a remote user. If the two remote source systems, rhost1 and rhost2, each expect a diferent form for the remote target, the comand: rcp rhost1:path1 rhost2:path2 rhost3.ruser3:path3 will certainly fail on one of the source systems. Perform such a transfer using two separate comands.

AUTHOR

rcp was developed by the University of California, Berkeley. SE ALSO cp(1), ftp(1), remsh(1), remshd(1M), rcmd(3), hosts(4), hosts.equiv(4).