Using FTP Commands to Operate Files

After logging in to an FTP server, you can use FTP commands to operate files, including configuring the file transfer mode, viewing online helps about FTP commands, uploading files, and managing directories and files.

Procedure

  1. Perform either of the following steps on the client, based on the type of the server's IP address:

    • Run the ftp [ [ -a source-ip-address | -i { interface-type interface-number | interface-name } ] host-ip [ port-number ] [ vpn-instance vpn-instance-name ] | public-net ] command to configure the device to use an IPv4 address to establish a connection to the FTP server and enter the FTP client view.
    • Run the ftp ipv6 [ -a source-ip6 ] host-ipv6-address [ [ vpn-instance ipv6-vpn-instance-name ] | public-net ] [ -oi { interface-type interface-number | interface-name } ] [ port-number ] command to configure the device to use an IPv6 address to establish a connection to the FTP server and enter the FTP client view.

  2. Perform one or more operations described in Table 1 as needed.

    Table 1 File operations

    File Operation

    Description

    Managing files

    Configuring the file type

    • Run the ascii command to set the file type to ASCII.
    • Run the binary command to set the file type to binary.

    The FTP file type is determined by the client. By default, the ASCII type is used.

    Configuring the data connection mode

    • Run the passive command to set the data connection mode to PASV.
    • Run the undo passive command to set the data connection mode to ACTIVE.

    Uploading files

    • Run the put local-filename [ remote-filename ] command to upload a file from the local device to a remote server.
    • Run the mput local-filenames command to upload files from the local device to a remote server.
    NOTE:
    You can also run either of the following commands in the user view to upload the local file to the FTP server:
    • On an IPv4 network:

      Run the ftp client-transfile put [ -a source-ipv4 | -i { interface-type interface-number | interface-name } ] host-ip ipv4-address [ port portnumber ] [ vpn-instance vpn-instancename | public-net ] username user-name sourcefile localfilename [ destination remotefilename ] command.

    • On an IPv6 network:

      Run the ftp client-transfile put ipv6 [ -a source-ipv6 ] host-ip ipv6-address [ [ vpn-instance ipv6-vpn-name ] | public ] [ port port-number ] username username sourcefile local-filename [ destination remote-filename ] command.

    Downloading files

    • Run the get remote-filename [ local-filename ] command to download a file from a remote server and save the file on the local device.
    • Run the mget remote-filenames command to download files from a remote server and save the files on the local device.
    NOTE:
    You can also run either of the following commands in the user view to download the local file to the FTP server:
    • On an IPv4 network:

      Run the ftp client-transfile get [ -a source-ipv4 | -i { interface-type interface-number | interface-name } ] host-ip ipv4-address [ port portnumber ] [ vpn-instance vpn-instancename | public-net ] username user-name sourcefile localfilename [ destination remotefilename ] command.

    • On an IPv6 network:

      Run the ftp client-transfile get ipv6 [ -a source-ipv6 ] host-ip ipv6-address [ [ vpn-instance ipv6-vpn-name ] | public ] [ port port-number ] username username sourcefile local-filename [ destination remote-filename ] command.

    Enabling the file transfer notification function

    • If the prompt command is run in the FTP client view to enable the file transfer notification function, the system prompts you to confirm the upload or download operation during file upload or download.
    • If the prompt command is run again in the FTP client view, the file transfer notification function is disabled.
      NOTE:

      The prompt command applies when the mput or mget command is used to upload or download files. If the local device has the files to be downloaded by running the mget command, the system prompts you to replace the existing ones regardless of whether the file transfer notification function is enabled.

    Enabling the FTP verbose function

    Run the verbose command.

    After the verbose function is enabled, all FTP response information is displayed. After file transfer is complete, statistics about the transmission rate are displayed.

    Enabling the function of appending the local file contents to the file on the FTP server

    Run the append local-filename [ remote-filename ] command.

    If the file specified by remote-filename does not exist on the FTP server, the file is automatically created on the FTP server, and the local file contents are automatically appended to the end of the created file.

    Deleting files from a server

    Run the delete remote-filename.

    Managing directories

    Changing the working path of a remote FTP server

    Run the cd pathname command.

    Changing the working path of an FTP server to the parent directory

    Run the cdup command.

    Displaying the working path of an FTP server

    Run the pwd command.

    Displaying files in a directory and the list of sub-directories

    Run the dir [ remote-directory [ local-filename ] ] command.

    If no path name is specified for a specified remote file, the system searches an authorized directory for a specified file.

    Displaying a specified remote directory or file on an FTP server

    Run the ls [ remote-directory [ local-filename ] ] command.

    Displaying or changing the working path of an FTP client

    Run the lcd [ directory ] command.

    The lcd [ directory ] command displays the local working path of the FTP client, while the pwd command displays the working path of the remote FTP server.

    Creating a directory on an FTP server

    Run the mkdir remote-directory command.

    The directory can be a combination of letters and digits and must not contain special characters, such as less than (<), greater than (>), question marks (?), backslashes (\), and colons (:).

    Deleting a directory from an FTP server

    Run the rmdir remote-directory command.

    Displaying online help for an FTP command

    Run the remotehelp [ command ] command.

    Enabling the resumable data transfer for the FTP client

    Run the ftp client resumable-transfer enable command in the system view.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >