Example: Copying a File Using the copy Command

This example shows you how to use the copy command to copy a file.

Requirements

This example uses the following software and hardware components:

Note: Before you copy the files, the following host entries should be defined in the host table:

  • host mary 172.28.32.156 ftp mike mikePwd
  • host joe 172.28.32.99 ftp joe jPasswd

Overview

You can use the system’s FTP server to transfer files between a network host and the user space. When a firewall separates the E Series router from the network host, you must use the FTP server to transfer files to the user space. You can then install the files from the user space to the system space by using the copy command. However, if there is no firewall between the E Series router and the network host, you can use the copy command, the remote FTP server, or the remote TFTP server to transfer files.

Copying a Remote File to a Local File

This section describes the following:

Copying a File Using the CLI File copy Command Format

Step-by-Step Procedure

You can create or replace the local file autocfg.scr by copying the remote file autocfg.scr located in the directory ftpDir/scripts on the host mary. The username mike and password mikePwd from the host entry mary are used to access the remote file.

  1. Issue the copy command in Privileged Exec mode.
    host1#copy mary:ftpDir/scripts/autocfg.scr autocfg.scr

Copying a File Using the URL Format

Step-by-Step Procedure

To create or replace the local file autocfg.scr by copying the remote file autocfg.scr located in the directory ftpDir/scripts on the host mary:

  1. Use the hostname to specify the location, and specify the username and password in the command. The username fred and the password passwd in the command are used; the username and password in the host entry are ignored.
    host1#copy ftp://fred:passwd@mary/ftpDir/scripts/autocfg.scr autocfg.scr
  2. Use the hostname to specify the location, specify the username in the command, and use the default value of the password. The username fred from the command and the default password null are used; the username and password in the host entry are ignored.
    host1#copy ftp://fred@mary/ftpDir/scripts/autocfg.scr autocfg.scr
  3. Use the hostname to specify the location. The protocol TFTP, which does not support usernames or passwords, is the protocol in the URL. The protocol specified in the command is used; the protocol for the host entry mary is ignored.
    host1#copy tftp://mary/ftpDir/scripts/autocfg.scr autocfg.scr
  4. Use the hostname to specify the location, and use the username and password from the host entry. The username mike and password mikePwd from the host entry are used.
    host1#copy ftp://mary/ftpDir/scripts/autocfg.scr autocfg.scr
  5. Use the host's IP address to specify the location, and the username fred to access the remote file.
    host1#copy ftp://fred@172.28.32.156/ftpDir/scripts/autocfg.scr autocfg.scr

Copying a Local File to a Remote File

This section describes the following:

Copying a File Using the CLI File copy Command Format

Step-by-Step Procedure

You can create or replace the remote file shConfigForJoe.txt in the directory ftpDir/results on the host joe by copying the local file shConfig.txt. The username joe and password jPasswd from the host entry joe are used to access the remote file.

  1. Issue the copy command in Privileged Exec mode.
    host1#copy shConfig.txt joe:ftpDir/results/shConfigForJoe.txt

Copying a File Using the URL Format

Step-by-Step Procedure

You can create or replace the remote file shConfigJoe.txt in the directory ftpDir/results on the host 172.28.32.156 by copying the local file shConfig.txt. The username joe and the password passwd from the command are used to access the remote file.

  1. Issue the copy command in Privileged Exec mode.
    host1#copy shConfig.txt ftp://joe:passwd@172.28.32.156/ftpDir/results/shConfigJoe.txt

Related Documentation