Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Using Your HP Workstation > Chapter 11 Communicating over a Network

Copying Files Remotely with rcp

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

You can use the HP-UX rcp (Remote Copy) program to copy files or directories to and from a remote system or to copy among remote systems.

Preparing to Use rcp

If your system administrator has already configured your system to use remsh, you can use rcp without any additional setup.

To use rcp, you will need the following:

  • Read permission on the files you want to copy, and read and search (execute) permission on all directories in the directory path.

  • An account (login) on the remote system.

  • A .rhosts file in the remote system's home directory containing the names of your local system and your local login name.

    For example, an entry in the .rhosts file on the remote system might be:

       hpabc leslie
    

    where hpabc is the name of your local system and leslie is your local login name. This allows leslie on hpabc to copy files back and forth to the remote system containing the .rhosts file.

NOTE: It is important to protect your remote .rhosts file and home directory to prevent unauthorized users from gaining rcp access to your remote account.
  • Make sure you own the file.

  • Make sure that you (the owner) have read and write permission on the .rhosts file, and that group and other have no permissions.

  • Protect your remote home directory so that owner has read, write, and execute permission, group has read and execute permission, and other only has execute permission.

For information on file ownership and permissions, see “File Ownership and Security”.

  • A .rhosts file on your local system. This contains the names of all the systems you will copy files to and from.

    For example:

       hpqrs leslie
    
       hpxyz leslie
    

  • If your system has an /etc/hosts file, the system administrator should ensure that it contains entries for the remote hosts with which you will communicate.

    The /etc/hosts file has a line containing the following information about each remote system:

       internet_address   official_name   alias
    

    For example:

       15.15.232.18    hpabc.fc.hp.com  hpabc
    

Copying Files to a Remote System

To copy from your system to a remote system, use the following:

   rcp local_file remote_hostname:remote_file Enter

Note that, if local_file is not in your current directory, you will need to supply the relative path (from your current directory) or the absolute path name (from /), in addition to the local file name.

Specify the complete (absolute) path for the remote_file on remote_hostname only if you want to place it in a directory other than the remote home directory.

Examples. To copy myfile from your current directory to a remote system called hpxyz:

   rcp myfile hpxyz:/home/leslie/otherdir Enter

In this case, myfile will be copied as myfile into the remote subdirectory, otherdir. If you had only supplied the remote host name, rcp would have copied myfile into the remote home directory, also as myfile.

You can also include a file name in the destination. For example, to copy to a system named hpxyz:

   rcp myfile hpxyz:/home/leslie/otherfile Enter

In this case, you have copied myfile as otherfile, in the remote directory leslie.

Copying Files from a Remote System

To copy a file from a remote system into your local directory, use the following syntax:

   rcp remote_hostname:remote_file local_file  Enter

Example. To copy myfile from your account in a remote system hpxyz into your current directory:

   rcp hpxyz:/home/leslie/myfile . Enter

The dot (.) is shorthand for "current directory". In this case, myfile will be copied from the remote directory into your current directory as myfile.

If you want to copy the file to a new name, supply the destination file name.

If you want to copy myfile into another directory in your home system, use a path name, absolute or relative, as shown:

   rcp hpxyz:/home/leslie/myfile otherdir/ Enter

Or, if you want to copy the file to another file name in another directory:

   rcp hpxyz:/home/leslie/myfile otherdir/otherfile Enter

Copying Directories to a Remote System

To copy a local directory with all its files and subdirectories to a remote system, use rcp with the -r (recursive) option.

The syntax is as follows:

   rcp -r local_dir remote_hostname:remote_dir Enter

If local_dir is not in your current directory, you will need to supply the relative path name (from your current directory) or the absolute path name (from /, the top of the directory hierarchy), in addition to the local directory name. Also, if remote_dir is not in your home directory, the remote_dir will require a relative path (from your home directory) or an absolute path (from /).

For more information, see “The Hierarchical File System”.

Example. To copy an entire subdirectory called work to a directory called products in your home directory on a remote computer called hpabc, type the following:

   rcp -r work hpabc:/home/leslie/products Enter

This command creates a directory named work, with all its contents, in hpabc:/home/leslie/products (provided that /home/leslie/products already exists on hpabc).

The example assumes that you are in the local directory containing work. Otherwise, you would have to give a relative or absolute path to that directory, such as /home/leslie/work.

Copying Directories from a Remote System

To copy a remote directory with all its files and subdirectories to a local directory, use rcp with the -r (recursive) option in the following syntax:

   rcp -r remote_hostname:remote_dir local_dir Enter

Example. To copy a remote directory called work to your current directory, type the following:

   rcp -r hpabc:/home/leslie/work . Enter

The dot (.) indicates the current directory. The work directory will be created in this directory.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© © 1983-1995 Hewlett-Packard Development Company, L.P.