# TCP/IP DOS Utilities #### Transferring Files Part 4/9

Previous: Emulating a Remote Terminal Next: Printing Files on Remote Printers

## Transferring Files

The LAN WorkPlace® utilities include three utilities to transfer files between your workstation and a remote host or between two remote hosts.

The FTP utility is based on the File Transfer Protocol and enables you to access files and directories on your workstation and remote hosts, transfer files, and perform basic directory and file operations. You can transfer files in the following ways:

You can transfer files from your workstation to a remote host.

You can transfer files from a remote host to your workstation.

You can transfer files between two remote hosts.

FTP uses passwords to authorize your access of remote hosts.

The RCP utility is based on the Remote Copy Protocol and enables you to transfer files to and from remote hosts that are running the RSH and RCP servers. Instead of using passwords, RCP uses entries in the hosts.equiv and .rhosts files on the remote host to authorize access.

The TFTP utility is based on the Trivial File Transfer Protocol and enables you to exchange individual files with remote hosts that use the TFTP protocol. TFTP does not use passwords.

### Transferring Files with the FTP Utility

The FTP utility performs common directory and file operations and transfers files between your workstation and a remote host running an FTP server program.

### Starting FTP

You can start FTP and log in to a remote host if you meet the following conditions:

You know the internet address of the remote host, or there is an entry for the remote host in either of the following hostname databases:

Domain Name System (DNS) name server (if your network has one)

HOSTS file in the \NET\TCP directory on your workstation

Your IP address is recognized as a valid address by the remote host.

You can provide a username, if one is required.

You can provide a password, if one is required.

When you start FTP, FTP connects your workstation to the remote host, prompts you to log in, and displays an FTP prompt at which you can enter FTP commands.

To start FTP, enter the FTP command at the DOS prompt in the following format:

>     FTP [-D] [-F] [-I] [-P] [-V] [-X] remote_host

The following table summarizes the FTP command-line options and parameters.

#### FTP Options and Parameters

Options and Parameters | Description -D | This option enables debugging. If you do not specify this option, FTP disables debugging.
-F | This option directs FTP to identify file structure and type automatically. If you do not specify this option, FTP assumes all files are text and must be transferred as ASCII files.
-I | This option disables interactive prompting during multiple file transfers. If you do not specify this option, FTP asks you to confirm the transfer of each file.
-P | This option directs FTP to prompt you for a password when you do not provide one with the USER command. This option is useful if you start FTP from a script file.
-V | This option displays all responses from the FTP server. If you do not include this option, FTP does not display all server responses.
-X | This option directs FTP to exit if any command fails. This option is useful only when running FTP from a script file.
remote_host | This parameter specifies the name or Internet address of the remote host. You can connect to an OS/2, DOS, UNIX, VAX/VMS, or other host that is running an FTP server program.

You can open additional FTP sessions with other hosts by typing the following command:

>     OPEN remote_host <Enter>

The last session you open is the current session. The session that was previously current becomes inactive.

### Using FTP Commands

After you start FTP, you can use FTP commands for operations such as copying files, displaying file and directory information, and changing the current directory.

To display a listing of the available commands, type the HELP command:

>     HELP <Enter>

If you have established a session with a remote host, HELP lists all the FTP commands; if you do not have an established session, HELP lists only the commands you can use without a session.

You can display information about a specific FTP command by typing the following command:

>     HELP FTP_command <Enter>

FTP commands include required parameters. If you type one of these commands without its parameters, FTP prompts you for the parameters before it executes the command. The following commands require parameters:

> APPEND
> CD
> DELETE
> GET
> MDELETE
> MGET
> MKDIR
> MPUT
> OPEN
> PUT
> QUOTE
> RECV
> RENAME
> RMDIR
> SEND

Some FTP commands require that you specify directories or files as local_directory, local_file, remote_directory, or remote_file. When you specify one of these directories or files, you must use identifiers recognized by the system on which those directories or files reside. Use DOS nomenclature to identify local directories and files; use UNIX nomenclature to identify directories and files on a UNIX host.

You can specify DOS filenames in the following format:

>     [ d: ] [ file_spec ]

where d: identifies the drive, and file_spec identifies the directory path, the name of the file, and the filename extension.

You can include spaces in a command argument by enclosing the argument in quotes ("").

>     PUT my_file "Your File"

The following table describes the FTP commands.

### FTP Commands

Command | Description APPEND local_file [ remote_file ] | This command appends a workstation file to a remote file. If you specify remote_file, FTP appends local_file to remote_file. If you specify remote_file but it does not exist, FTP creates remote_file. If you omit remote_file, FTP copies local_file to a new file with the same name in the current remote directory. FTP uses the current settings for FORMAT, MODE, STRUCTURE, and TYPE during file transfers.
ASCII | This command sets the file transfer type to ASCII (the default type). You can use this command only with an active connection to a host. For information on the other file transfer type, see the BINARY command in this table.
BELL | This command toggles a bell sound after each FTP operation is completed.
BINARY | This command sets the file transfer type to binary image transfer. You can use this command only with an active connection to a host. For information on the other file transfer type, see the ASCII command in this table.
BYE | This command terminates all FTP sessions, exits from FTP command mode, and returns to DOS. This command is the same as the QUIT command, described in this table.
CD remote_directory | This command changes the current working directory on the remote host to remote_directory. FTP prompts you for a password if the remote host requires one. The remote directory can include a device ID (for example, logical drive G:) if the remote host and FTP server support drive names. If you omit remote_directory, FTP prompts you for the directory name.
CLOSE [ hostname [ ... ] ] | This command terminates an FTP session with the remote server, but remains in FTP command mode. If you specify one or more hostname, FTP terminates the sessions with those hosts only. If you omit hostname, FTP terminates only the active session.
COPY [ -A | -B ] [ - F ] [ -I ] [ -R ] source destination | This command copies one or more files or directories. You can execute this command on the current connection or any idle connection. If source is a file, destination can be a file or a directory. If source is more than one file, one or more directories, or a filename containing wildcard characters, you must specify a directory for destination. The destination parameter cannot contain wildcard characters. FTP assumes that the last file or directory name in the command line is the destination. If you want to copy files between two directories on your workstation or on the same remote host, you can use LCD or CD to change the current directory setting to the destination directory, then execute the COPY command without specifying destination. If any of the source or destination files or directories you specify reside on an idle host or on a host that you have not opened with an OPEN command (such as NVTOPEN, OPEN, or TELOPEN), the COPY command opens connections to those hosts. After FTP copies the files, FTP resets the connections to the initial states. The number of remote hosts and the depth of the directory tree that are accessible using the COPY command are limited by the resources available on the various hosts, especially on the local host (your workstation), which is the one most likely to run out of memory. You can specify options and parameters with the COPY command. When you specify more than one option, you can combine the options and precede them with a single hyphen. For example, both -AF and -A -F produce the same results. Include -A to transfer files in ASCII mode. If FTP determines that the file is a binary file, it transfers the file as a binary file unless you also specify the - F option to force an ASCII-mode transfer. When you first open a connection, ASCII is the default value; afterward, the connection retains the option you most recently specified with the -F option. Include -B to transfer files in Binary mode. If FTP determines that the file is an ASCII file, it transfers the file as an ASCII file unless you also specify the -F option to force a binary-mode transfer. When you first open a connection, ASCII is the default value; afterward, the connection retains the option you most recently specified with the -F option. Include -F to transfer files as specified by the -A or -B option. If you use this option without specifying the -A or -B option, it forces the file type to be the most recently specified option (-A or -B). If the COPY command opens the connection needed to transfer the file or files, the file transfer type is ASCII. If COPY uses an open connection, it uses the file transfer type currently in effect. The -F option operates independently from the FORCE command described in this table. Include -I to ignore files with invalid DOS filenames when copying files to your PC workstation. Include -R to copy directories recursively (the directory and all its subdirectories). You must include this option if source is a directory that contains one or more directories. FTP places the subdirectories in the directory specified by destination. This option does not allow names with wildcard characters in source. Recursive copying works with most servers that support tree-like file structures. Include source to name one or more files or directories you are copying. You can specify names as follows: filename --- a file on your workstation. filename can be in the current directory, or you can specify a full or partial pathname. remote_host=filename --- a file on the remote host. filename can be in the current directory, or you can specify a full or partial pathname. filename must be in a format understood by the remote host. [user@]remote_host[:password]=filename --- a file on the remote host in the account of user. If you do not specify the user's name or password and one is required, FTP prompts you for it. directory --- a directory on your PC workstation. directory can be located in the current directory, or you can specify a full or partial pathname. remote_host=directory --- a directory on the remote host. directory can be in the current directory, or you can specify a full or partial pathname. [user@]remote_host[;password]=directory --- a directory in the user account on the remote host. If you omit the user's name or password and one is required, FTP prompts you for it. Include destination to specify the destination file or directory. If destination is a file, you can specify it as filename, remote_host=filename, or [user@]remote_host [:password]=filename. If destination is a directory, you can specify it as directory, remote_host=directory, or [user@]remote_host [;password]=directory. If destination is a directory, it must exist before you execute the COPY command, unless you include the -R option. (The -R option creates subtrees in destination_directory.)
DEBUG | This command activates and deactivates debugging mode. When debugging is on, FTP displays each command sent to the remote host after you establish a session. The default setting is OFF. This command has the same effect as the -D command-line option.
DEFAULTS | This command restores the DEBUG, SENDPORT, and VERBOSE values to their default settings. You can use this command only when you have an active connection.
DELETE remote_file | This command deletes a file from the remote host. If you include wildcards in remote_file, you can get unpredictable results---these characters are used differently by different systems. For example, UNIX systems return an error when you use wildcards. If you omit remote_file, FTP prompts you for a filename.
DIR [ remote_directory [ local_file ] ] | This command displays a detailed list of files in the current directory on the remote host. If you specify remote_directory, FTP displays a list of files in that directory. If you specify local_file, FTP redirects the list to the file that you specify. The local_file can be in the current directory, or you can specify a full pathname.
EXEC "command" | This command executes command on the remote host. The command you specify must be recognized by the remote host and you must include all required arguments. You can use this command only when you have an active session with a remote host that supports the XEXC FTP protocol element. When the host completes its execution of your command, FTP displays its prompt. If you specify ! as command, FTP calls the remote command interpreter. You can specify a command that calls line-oriented interactive programs, such as rm -I orlpq, but not a command that calls screen oriented programs, such as vi or more. If you specify a command with arguments that contain spaces or more than one word, enclose the command and its arguments in quotation marks.
FILE | This command sets the file transfer structure to FILE, an unstructured byte stream. The other available file transfer structure is RECORD, a series of data records separated by delimiters. You can use this command only when you have an active connection with a remote host. This command affects only the active connection.
FORCE | This command switches how FTP determines file transfer types. When FORCE is on, FTP transfers files according to the current settings of the TYPE parameter. When FORCE is off, FTP attempts to determine the file type before transferring it (this has the same effect as specifying the -F command-line option). If FTP cannot determine the file type, it transfers the file according to the current file type setting. This command affects only the active connection.
FORMAT [ format ] | This command displays the current file transfer format. The default format is NONPRINT. This is the only format that FTP currently supports. This command only affects the active connection with a remote host.
GET remote_file [ local_file | local_directory ] | This command copies remote_file from the remote host to a file on your workstation. If you omit remote_file, FTP prompts you for the name. If you specify local_file, FTP renames remote_file as local_file as it copies the file to your workstation. If you specify local_directory, FTP copies remote_file into that directory, keeping the same filename. If you specify a - (hyphen) for local_file, FTP redirects the file to your screen. FTP uses the current settings for TYPE, FORMAT, MODE, and STRUCTURE during file transfers. This command is equivalent to the RECV command, described in this table.
HASH | This command prints a number sign (#) as FTP transfers each 1024 bytes of data. When FTP prints number signs, its transfer rate slows down. HASH is a toggle command. To stop FTP from printing this character, type the HASH command again. The default setting for this command is OFF.
HELP [ command [ ... ] ] | This command lists the available FTP commands. If you specify command, FTP displays a single-line description of that command. The HELP command is equivalent to the ? command.
LCD [ local_directory ] | This command changes the current working directory on your workstation to local_directory. If you omit local_directory, the directory you were in when you started FTP becomes the current directory.
LDIR [ local_directory [ ... ] | local_file [ ... ] ] | This command displays a detailed list of files in the current directory on your PC workstation. If you specify local_directory, FTP lists the contents of that directory. If you specify a drive for local_directory, FTP lists the contents of the current directory on that drive. If you specify local_file (with or without DOS wildcard characters) FTP lists any files matching that name in the current directory.
LEXEC [ "command" ] | This command escapes to DOS on your workstation and enables you to execute DOS commands. If you specify command, DOS executes the command, then returns control to FTP. All open sessions remain open. This command is useful for executing DOS commands from FTP scripts.
LLS [ local_directory [ ... ] | local_file [ ... ] ] | This command displays a brief listing of the contents of the current directory on your workstation. If you specify a drive, FTP lists the contents of the current directory on that drive. If you specify local_directory, FTP lists the contents of that directory. If you specify local_file (with or without DOS wildcard characters), FTP lists any files matching that name.
LPWD | This command displays the name of the current drive and working directory on your PC workstation.
LS [ { remote_directory | remote_file } [ local_file ] ] | This command displays a list of the contents of the current directory on the remote host. If you specify remote_directory, FTP displays the contents of that directory. If you specify remote_file, FTP lists any files matching that name (you can include wildcard characters to specify more than one file). If you specify local_file, FTP redirects the list to this file on your PC workstation. The local_file can be in the current directory, or you can specify a full path name.
MDELETE remote_file [ ... ] | This command deletes files from the remote host. You can include any wildcard characters in remote_file that the remote host understands.
MDIR [ { remote_directory | remote_file } [ ... ] local_file ] | This command lists the detailed contents of one or more remote directories or lists one or more remote files. If you specify remote_file or remote_directory, FTP lists the contents of the files or directories you specify. If you specify local_file, FTP directs the information to local_file on your PC workstation. FTP assumes that the last file or directory in the command list is a local_file. If you specify local_file as a hyphen (-), FTP redirects the information to your screen.
MGET remote_file [ ... ] | This command copies one or more files from the remote host to the current working directory on your workstation. To specify remote_file, you can use any wildcard characters that the remote host understands; wildcard characters are expanded on the remote host.
MKDIR remote_directory | Creates remote_directory on the remote host. The directory you specify cannot already exist. If you include a pathname in remote_directory, you can create a directory outside the current directory.
MLS [ { remote_directory | remote_file } [ ... ] local_file ] | This command displays a list (file and directory names only) of the contents of the current directory on the remote host. If you specify remote_file or remote_directory, FTP lists the files or the contents of the directories you specify. If you specify local_file, FTP directs this information to local_file on your workstation. The last file in the command list is interpreted as local_file. If you type a - (hyphen) for local_file, FTP redirects this information to your screen. If you specify more than one remote directory or file, FTP requires that you also specify a local_file or the hyphen character; otherwise FTP tries to save the listing under the last directory or filename you specify.
MODE [ mode_name ] | This command displays the current mode. If you specify mode_name, FTP sets the file transfer mode to mode_name. The default mode is STREAM. This is the only mode that FTP currently supports. This command only affects the active connection with a remote host.
MPUT local_file [ ... ] | This command copies multiple files from your workstation to the current directory on the remote host. You can include wildcard characters that DOS understands in the local_file. If you omit local_file, FTP prompts you for the filename. If you want to rename the file you are copying, use the PUT or SEND command (described in this table).
OPEN hostname [ port ] | This command opens a connection to the FTP server on remote host hostname if one does not already exist. If you do not specify hostname, FTP prompts you for it. FTP also prompts you for the username and password you need to access that remote host. After you have successfully supplied the required information, FTP makes the new connection the current connection. The previous connection, if any, becomes idle. You can use the OPEN command to activate an idle session. If you specify port, FTP attempts to contact an FTP server at that port. The default port for FTP is 21. If you issue the OPEN command from a script file, you must include the USER command to specify the username and password, if required.
> PROMPT | This command activates and deactivates interactive prompting for multiple file transfers. When prompting is on, FTP pauses before sending or receiving the first file and prompts you as follows:
>     (n==don't, a==do all, q==do no more, y==do) ?
If you press Y or N, FTP repeats the prompt for the next file. If you press A, FTP copies the rest of the files without further prompting. If you press Q, FTP does not copy the rest of the files and the transfer command ends. When PROMPT is off, any MGET, MPUT, and MDELETE command operates on all the files specified in the command line without FTP prompting.
PUT local_file [ remote_file | remote_directory ] | This command copies a file from your workstation to the current directory on the remote host. If you omit local_file, FTP prompts you for the filename. If you specify remote_file, FTP copies local_file to this name. If you specify remote_directory, FTP copies local_file into remote_directory without changing its filename. FTP uses the current settings for TYPE, FORMAT, MODE, and STRUCTURE, as described in this table, during file transfers.
PWD | This command displays the name of the current working directory on the remote host.
QUIT | This command terminates all FTP sessions with all remote servers, exits FTP command mode, and returns to the DOS prompt. This command is equivalent to the BYE command, described in this table.
QUOTE "protocol_element" | This command sends an FTP protocol element to the FTP server, bypassing normal command parsing. Incorrect specification of the FTP protocol element can make your current FTP session useless. Protocol elements that require data transfers can interfere with the current FTP session. This command should be used only by those who know FTP protocol. You can use this command only when you have an active connection with an FTP server on a remote host. The FTP protocol element and its parameter must be enclosed in quotation marks (for example, QUOTE "ACCT xyz"). Use the REMOTEHELP command, described in this table, to list the supported FTP protocol elements.
RECORD | This command sets the file transfer structure to RECORD and partitions files into records. The other file transfer structure is FILE, an unstructured byte stream. This command affects only the active connection with a remote host. This command does not function if the FTP protocol element STRU is not implemented on the remote host.
RECV remote_file [ local_file ] | This command copies remote_file from the remote host to your workstation. If you omit remote_file, FTP prompts you for the filename. If you specify local_file, FTP copies remote_file to that name. If you omit local_file, FTP copies remote_file to the current directory on your workstation without changing the filename. If you specify a - (hyphen) for local_file, FTP redirects the file to the screen. FTP uses the current settings for TYPE, FORMAT, MODE, and STRUCTURE, all described in this table, during file transfers. This command is equivalent to the GET command, also described in this table.
REMOTEDIR | This command treats FTP transfer objects as files (instead of checking to see if the objects are directories). By default, REMOTEDIR is disabled and FTP verifies whether transferred objects are files or directories. When FTP determines that it is exchanging objects with an MVS host, it enables REMOTEDIR so that it can transfer all objects as files without verification.
REMOTEHELP [ protocol_element [ ... ] ] | This command lists the protocol elements for the remote FTP server. If you specify protocol_element, FTP lists information about that protocol element. You can use REMOTEHELP only when you have an active connection with a remote host.
REMOTESTATUS [ remote_file ] | This command displays the status of the remote FTP server. If you specify remote_file, FTP displays the status of that remote file or directory. This command does not function if the FTP protocol element STAT is not implemented on the remote host.
RENAME remote_file1 remote_file2 | This command renames the file remote_file1 to remote_file2 on the remote host.
RGET remote_file [ local_file ] | This command copies remote_file from the remote host to your workstation as a record-structured file. If you omit remote_file, FTP prompts you for a filename. If you specify local_file, remote_file is copied to that file. If you omit local_file, FTP copies remote_file to your workstation without changing the filename. If you specify a - (hyphen) for local_file, FTP displays remote_file on the screen instead of copying it to a file. If the current file transfer structure is not RECORD when you issue the RGET command, FTP restores the file structure to its previous setting upon completion of this command.
RMDIR remote_directory | This command deletes the directory remote_directory from the remote host. The remote directory must be empty before you can delete it.
RPUT local_file [ remote_file ] | This command copies a record-structured local_file to a file on the remote host. If you specify remote_file, FTP copies local_file to the remote_file. If the current file transfer structure is not RECORD, FTP restores the file structure to its previous setting upon completion of this command.
SEND local_file [ remote_file ] | This command copies local_file from your workstation to the remote host. If you omit remote_file, FTP copies the file to the current directory on the remote host without changing the filename. If you specify remote_file, FTP copies local_file to the remote host and renames the file remote_file. FTP uses the current settings for TYPE, FORMAT, MODE, and STRUCTURE, all described in this table, during this file transfer.
SENDPORT | This command switches the use of the PORT protocol element. When SENDPORT is active (the default setting), the FTP server attempts to use the port you specify when you establish a remote connection. If this fails, the FTP server uses the default data port (port 20) and connects to the same port used by the FTP command connection. When SENDPORT is off, the FTP server uses the default port. You can use this command for certain FTP server implementations that ignore port commands but incorrectly indicate that they have been accepted.
STATISTICS | This command toggles the display of transfer statistics after the application copies each file.
STATUS | This command displays the current state of all FTP options and the current connection (if there is one). This command also displays a list of idle connections.
STRUCTURE [ structure_name ] | This command displays the current file transfer structure. If you specify structure_name, FTP sets the file transfer structure to that structure. The default file transfer structure is FILE. The other supported structure is RECORD. This command affects only the active connection.
TYPE [ type_name ] | This command displays the current file transfer type. If you specify type_name, the file transfer type is set to that type. The default file transfer type is ASCII. The other supported types are BINARY (image) and LOCAL 8 (which sets the byte size to eight bits). This command affects only the active connection.
USER username [ [ password ] account ] | This command logs in to the remote FTP server. If you omit password or account and the server requires them, FTP prompts you for the missing information. If you do not specify either one when FTP prompts you, FTP does not establish a connection. If you start FTP from a script file, you must use this command to log in to the server after the script file opens a session.
VERBOSE | This command toggles VERBOSE mode. By default, VERBOSE is off. When VERBOSE is on, FTP displays all responses from the FTP server. When activated, this command has the same effect as the -V command-line option (see Table 4-1 on page 4-2).
? [ command [ ... ] ] | This command lists all FTP commands. If you specify command, FTP displays information about that command. This command is equivalent to the HELP command, described in this table.
! [ "command" ] | This command suspends the FTP session and returns to the DOS prompt so you can execute DOS commands. To return to FTP command mode, type EXIT. To execute a single DOS command and immediately return to FTP command mode, use the LEXEC command, described in this table.

### Displaying File and Directory Information

When you first open a session with a remote host, you are in your home directory on that host. Display the full path name of this directory by typing the following command at the FTP prompt:
PWD <Enter>

FTP displays information similar to the following:

>     "/x/sales/evelyn" is current directory.

You can list the contents of a directory by typing either of the following commands:

>     DIR [ directory_name ] <Enter>

>     LS [ directory_name ] <Enter>

If you do not specify directory_name, FTP lists the contents of the current directory. When the remote host is running the UNIX operating system, the DIR command displays a detailed list of the directory contents similar to the one shown below:

#### DIR Listing for a Remote UNIX Host

The LS command displays only the filenames for the remote host; for example:

>     calendar

>     general

You can change directories on the remote host by entering the following command:

>     CD remote_directory <Enter>

You can specify a directory name or path name for remote_directory. Specify a directory name if you want to change directories to a subdirectory in the current directory; specify a path name if you want to change to another directory.

> Note: Specify the name of the remote directory in a form that the remote host understands. For example, if the remote host is running UNIX, separate directory names with slashes (/); if the remote host is a VMS host, separate the directory names with periods (.) and enclose them in square brackets ([ ]).

You can perform the same operations on local files and directories on your workstation using the LPWD, LDIR, LLS, and LCD commands. The letter L at the beginning of each of these command names indicates that FTP is to perform each of these commands locally.

The LDIR command produces a detailed file listing similar to the listing produced by the DIR command. Unlike the DIR command, LDIR can also display DOS file attributes that indicate whether files are read-only (R) or have been modified since the last backup (A). The LDIR command displays these attributes on the right side of the directory listing.

### Transferring Text and Binary Files

By default, FTP transfers files in ASCII format. Before you can copy binary files, such as executable files, you must change the transfer mode from ASCII to binary.

You can determine whether the transfer mode is set for ASCII or binary by entering the following command at the FTP prompt:

>     STATUS <Enter>

A typical FTP response to a STATUS command is:

>     Connection-independent Flags:
>         Transfer files according to current transfer parameter settings.
>         Print transfer statistics.
>         Prompt during m[ultiple] commands.
>         Client specifies data connection port.
>     Connected to sales
>     Current transfer type is ascii.
>     Current transfer format is nonprint. Current file structure is unstructured (file).
>     Current transfer mode is stream.

When FTP is in binary mode, the STATUS message displays the following line:

>     Current transfer type is binary

The following examples show how to change the transfer mode:

To transfer all files in BINARY mode, type the following command:

>     BINARY <Enter>

To transfer all files in ASCII mode, type the following command:

>     ASCII <Enter>

To have FTP determine whether a file needs to be transferred in ASCII or binary mode, type the following command:

>     FORCE <Enter>

FORCE is a toggle command. When you start FTP, FORCE is active. Therefore, the first time you enter the FORCE command, you turn FORCE off. When you turn FORCE off, FTP displays the following message

>     :
>     Use file attributes to determine the file transfer parameters

When you enter this command again and turn FORCE on, FTP displays the following message:

>     Always use current transfer mode for file transfer

When FORCE is on, FTP transfers files according to the current transfer setting, either ASCII or binary mode. When FORCE is off, FTP determines the type of file to be transferred before transferring it. If a file contains text, FTP transfers it in ASCII mode; if it is an executable file, FTP transfers it in binary mode.

The FORCE command does not work when you are transferring files from the remote host to your workstation, unless the remote host is running a Novell® or an Excelan® FTP server program.

You can use the FTP STATUS command to determine whether FORCE is on or off. The STATUS command displays the following message when FORCE is on:

>     Transfer files according to current transferparameter settings.

When FORCE is off, the message is not displayed.

### Copying Files

FTP enables you to perform the following copy tasks:

- You can copy files from your workstation to a remote host.
- You can copy files from a remote host to your workstation.
- You can copy files between two remote hosts.

The following sections describe these copy tasks.

### Copying Files to a Remote Host

You can copy files from your workstation to a remote host in the following ways:

You can copy a file to a remote host by entering a command in one of the following formats:

>     PUT local_file [remote_file]
>     SEND local_file [remote_file]
>     COPY [-A | -B] [-F] local_file remote_host={remote_file remote_directory}

If you do not specify remote_file for the PUT and SEND commands, FTP gives the copied file the same name as the original on your workstation. For information on using the COPY command, see "Copying Files and Directories Using the COPY Command".

You can copy multiple files to the current directory on the remote host by entering a command in one of the following formats:

>     MPUT local_file [ ...]
>     COPY [-A] | -B] [-F] -R local_directory hostname=remote_directory
>     COPY [-A] | -B] [-F] local_file remote_host=remote_directory

With the MPUT command, you can specify multiple filenames by either including each filename after the command or including wildcard characters in one or more filenames. For information on using the COPY command, see "Copying Files and Directories Using the COPY Command".

You can copy a record-structured file by entering a command in the following format:

>     RPUT local_file [ remote_file ]

If you do not specify remote_file for the RPUT command, FTP gives the copied file the same name as the original file on your workstation.

> Note: If the remote host uses a case-sensitive operating system, such as UNIX, you must specify remote filenames in the appropriate case. Note: To abort a file transfer, press Ctrl+C or Ctrl+Break. For this to work, you must start your workstation with BREAK ON set in your AUTOEXEC.BAT file.

The following examples show how to copy files using the PUT, MPUT, RPUT, and SEND commands. In each of these examples, REPORT.DOC is an unstructured file (not a record-structured file) and RECFILE.DBM is a record-structured file.

You can copy the REPORT.DOC or RECFILE.DBM file from your workstation to the current directory on a remote host without changing the filename by typing one of the following commands:

>     PUT REPORT.DOC <Enter>
>     SEND REPORT.DOC <Enter>
>     RPUT RECFILE.DBM <Enter>

You can copy the REPORT.DOC or RECFILE.DBM file from your workstation to the reports directory on a remote UNIX host and rename the file to report.txt or report.dbm by typing one of the following commands:

>     PUT REPORT.DOC /reports/report.txt <Enter>
>     SEND REPORT.DOC /reports/report.txt <Enter>
>     RPUT RECFILE.DBM /reports/report.dbm <Enter>

You can copy the REPORT1.DOC and REPORT2.DOC files from your workstation to a remote host by typing one of the following commands:

>     MPUT REPORT1.DOC REPORT2.DOC <Enter>
>     MPUT REPORT*.DOC <Enter>

For information on using wildcard characters, see "Using Wildcard Characters".

### Copying Files to Your Workstation

You can copy files from a remote host to your workstation in the following ways:

You can copy a file from a remote host by entering a command in one of the following formats:

>     GET remote_file [local_file | local_directory]
>     RECV remote_file [local_file]
>     COPY [-A | -B] [-F] remote_host=remote_file local_file

If you do not specify local_file for the GET and RECV commands, FTP gives the copied file the same name as its original on your workstation. For information on using the COPY command, see "Copying Files and Directories Using the COPY Command".

You can copy multiple files from the remote host by entering a command in one of the following formats:

>     MGET remote_file [ ...]
>     COPY [-A | -B] [-F] -R hostname=remote_directory local_directory

With the MGET command, you can specify multiple filenames by either including each filename after the command or including wildcard characters in one or more filenames. For information on using the COPY command, see "Copying Files and Directories Using the COPY Command".

If you specify a filename only for remote_file, MGET copies that file from the current directory on the remote host. If you specify a path name, MGET copies the file from the directories you include in the path.

You can copy a record-structured file to your workstation by entering a command in the following format:

>     RGET remote_file [ local_file ]

If you specify local_file, FTP copies remote_file to the local_file name. If you do not specify local_file, FTP copies remote_file without changing the name.

The following examples show how to copy files using the GET, MGET, RGET, and RECV commands. For each of these examples, report.doc is an unstructured file (not a record-structured file) and recfile.dbm is a record-structured file.

You can copy the report.doc or recfile.dbm file from the current directory on a remote host to the current directory on your workstation without changing filenames by typing one of the following commands:

>     GET report.doc <Enter>
>     RECV report.doc <Enter>
>     RGET recfile.dbm <Enter>

You can copy the report.doc or recfile.dbm file from the current directory on a remote host to the REPORTS directory on your workstation and rename the file to REPORT.TXT or REPORT.DBM by typing one of the following commands:

>     GET report.doc REPORTS\REPORT.TXT <Enter>
>     RECV report.doc REPORTS\REPORT.TXT <Enter>
>     RGET recfile.dbm REPORTS\REPORT.DBM <Enter>

You can copy report1.doc and report2.doc from a remote host to the current directory on your workstation without changing the filenames by typing one of the following commands:

>     MGET report1.doc report2.doc <Enter>
>     MGET report*.doc <Enter>

For information on using wildcard characters, see "Using Wildcard Characters".

### Copying Files and Directories Using the COPY Command

The COPY command copies files between your workstation and a remote host, or between two remote hosts. It also copies an entire directory tree (including all subdirectories and files).

> Note: When you use the COPY command, FTP automatically opens connections to the remote hosts (if they are not yet open), copies the specified files, and closes the connections when it is finished copying the files.

You can copy one or more files by typing the COPY command in the following format:

>     COPY [ -A | -B ] [ -F ] [ -I ] [ -R ] [ remote_host=] { filename | directory_name }
>     [ remote_host= ] {filename | directory_name }

The following table describes each of the options and parameters you can include with the COPY command.

#### Copy Command Options and Parameters

Options and Parameters | Description -A | This option transfers files in ASCII format unless the files indicate that they are in binary format. If a file is in binary format, FTP copies it in binary format unless you also specify the -F option to force FTP to copy files in ASCII format.
-B | This option copies files in binary format unless the files indicate that they are in ASCII format. If a file is in ASCII format, FTP copies it in ASCII format unless you also specify the -F option to force FTP to copy files in binary format.
-F | This option forces either ASCII or binary format on the current file transfer. If you specify -A or -B with the COPY command, the command forces that format despite the format indicated by the file. If you do not include the -A or -B options when you use the -F option, FTP uses the file transfer option that you most recently specified. If the COPY command opens a connection to a remote host, it uses the file transfer type in effect on that host.
-I | This option ignores files with invalid DOS names when you are copying files from a host.
-R | This option copies subdirectories when you copy a directory.
remote_host= | This parameter specifies the remote host where FTP can find the filename or directory_name you specify. If you do not specify a remote host, FTP assumes that filename or directory_name is located on your workstation.
filename | directory_name | This parameter specifies the file or directory you are using as a source or destination for your copying.

You can use the COPY command in the following ways:

You can copy one or more files (report1.doc and report2.doc) from a remote UNIX host (unix1) to a directory (REPORTDIR) on your workstation by typing the following command:

>     COPY unix1=report*.doc REPORTDIR <Enter>

You can include wildcard characters with filenames. Be sure to use wildcard characters understood by the workstation or host you are using. For information on including wildcard characters, see "Using Wildcard Characters".

You can copy a directory (/finance/reports) from a remote UNIX host (unix1) to a directory (REPORTDIR) on your workstation by typing the following command:

>     COPY [-R] unix1=/finance/reports REPORTDIR <Enter>

If you do not include the -R option, FTP copies only the files within the specified directory. If you include the -R option, FTP copies the contents of the specified directory as well as the contents of the subdirectories. You cannot include wildcard characters in a filename when you use the -R option.

You can copy a file (REPORT1.DOC) from your workstation to a directory (reports) on a remote UNIX host (unix1) by typing the following command:

>     COPY REPORT1.DOC unix1=reports <Enter>

You can copy a directory (REPORTS) on your workstation to a directory (REPORTS:[RPT2]) on a VMS host (VMSHOST) by typing the following command:

>     COPY [-R] REPORTS VMSHOST=REPORTS:[RPT2] <Enter>

Each host uses a different syntax to define directories. UNIX separates a directory from its subdirectories with a slash (/); VMS uses a period and encloses the directories with brackets ([ ]).

You can copy a file (REPORTS TXT) from a VM host (VMSYS) to another filename (current.doc) on another host (unix1). Before you type this command, change the current directory to the minidisk that contains the file you are going to copy and enter the password for the minidisk. Once you access the minidisk, type the following command:

>     COPY VMSYS=REPORTS.TXT unix1=current.doc <Enter>

You must include a period between the VM filename and its extension (for example, you type REPORTS TXT as REPORTS.TXT). Although VM does not use a period between the filename and extension, DOS requires it.

### Using Wildcard Characters

You can include wildcard characters with FTP commands that have a file or directory name as a parameter by doing the following:

- You can include an asterisk (*) to represent any number of characters in that position.
- You can include a question mark (?) to represent any single character in that position.
- You can include a percent sign (%) to represent any single character in that position on a remote VMS host.

Wildcard characters are interpreted on the remote host according to the remote host's conventions. The following examples show how to use these characters when the remote host is running DOS, OS/2, UNIX, or VMS:

You can specify DOS or OS/2 files with the name ABC and any file extension:

>     ABC.*

You can specify all DOS or OS/2 filenames beginning with ABC and ending with three-letter file extensions beginning and ending with the letter T:

>     ABC*.T?T

You can specify all UNIX or VMS filenames beginning with the four characters ABC. (a period is included as a character in the filename):

>     ABC.*

You can specify all DOS or OS/2 files that have the extension OC preceded by any other single character:

>     *.?OC

You can specify all UNIX files that have names ending in a four-character extension of which the last two letters are OC:

>     *.??OC

You can specify UNIX filenames that begin with Nov, followed by any three characters and end with Inc:

>     Nov???Inc

You can specify VMS files with a four-character extension beginning with a period and ending with an OC:

>     *.%OC

### Suspending FTP and Executing Local DOS Commands

You can suspend the FTP utility at any time and execute local DOS commands by entering either of the following commands:

>     ! [ "command" ]
>     LEXEC [ "command" ]

If you specify command in quotes, FTP executes that command and stays in FTP command mode. If you omit command, FTP suspends itself and starts a new DOS session with a DOS prompt. You are at the drive and in the directory where you started the FTP session, and you can execute any DOS command. While FTP is suspended, all connections you opened during the FTP session remain open (unless the remote host closes the connection).

To return to FTP, type the following DOS command:

>     EXIT <Enter>

The DOS session closes, and FTP is reactivated. FTP displays its prompt and is ready for you to enter FTP commands.

If you use the DOS SET command while FTP is suspended, any characteristics you set affect only that DOS session. When you exit FTP and return to the original DOS session, all SET characteristics are restored to their previous values.

### Quitting FTP

When you finish an FTP session with a remote host, you can quit FTP and return to the DOS prompt by typing either of the following commands:

>     QUIT <Enter>
>     BYE <Enter>

When you exit FTP and return to the DOS prompt, you are at the drive and in the directory where you were before you started FTP. Any characteristics defined during the FTP session with the DOS SET command are restored to their previous values.

### Entering FTP Commands from a Script File

You can execute FTP commands from a script file. A script file is a file containing a sequence of commands. Here is a sample script:

>     OPEN
>     SALESUSER darrel heimdall
>     LCD \NET\TCP
>     GET HOSTS hosts.new
>     CLOSE
>     BYE

Script files should include the USER command after the OPEN command. This identifies the username, password (optional), and account (required for VM systems). If you do not include these items and the remote host requires them, FTP prompts you for them.

You can execute a script file by typing the following command:

>     FTP [ -X ] [ -P ] script_file <Enter>

Replace script_file with the name of the script you are running.

Include the -X option if you want FTP to exit when any command in script_file fails. Otherwise, if you open an FTP session from a script file and an error is detected during execution, the script file does not abort.

Include the -P option if you want FTP to prompt you for a password. This minimizes security problems by not leaving your password in the script file where others can access it. If the remote system requires a password and you neither provide one in the script file nor enter one interactively when FTP prompts you, FTP does not access the remote host or execute the remaining commands in your script file.

Like the USER command, some other FTP commands require parameters. If you do not include the required parameters with those commands in the script file, FTP halts execution and prompts you for those parameters. Refer to Table 4-2 on page 4-5 for the parameters that each command requires.

### Entering FTP Protocol Elements

If you are a developer or an advanced user, you might need to perform FTP operations with the FTP server on the protocol level.

Once you have established an FTP session, you can type the following command to request that the FTP server send a list of protocol elements that you can use to communicate with it.

>     REMOTEHELP <Enter>

#### Listing of FTP Protocol Elements

To send an FTP protocol element to the FTP server, type the following command, enclosing the protocol element in quotes ("").

>     QUOTE "protocol_element" <Enter>

Warning: FTP protocol elements that transmit data over a separate data connection, such as RETR (retrieve) or STOR (store), can cause the FTP server to hang.

### Transferring Files with the RCP Utility

The Remote Copy Program (RCP) utility lets you copy files and directories between your workstation and a remote host running the remote shell server, rshd, and an RCP server program. The RCP server uses entries in hosts.equiv or .rhosts (on the remote host) to authorize your access. RCP does not prompt for passwords.

To use RCP, you must have the system administrator for the remote host add your workstation IP address and username to the hostname database (/etc/hosts on UNIX systems). In addition, the remote host must meet one of the following conditions:

- The .rhosts file in the home directory of the remote account must list you as a user with access to that account.
- The remote host's hosts.equiv file must list your workstation. Your username must be the same as your login account name on the remote host.

RCP determines your username from the DOS environment table. Your username is specified with the SET NAME command. The SET NAME command is placed in your LANWP.BAT file when you install the LAN WorkPlace software. If your username is case sensitive, you must specify it in the appropriate case.

Once you have met these requirements, you can use the RCP utility. When you transfer files with RCP, the following changes occur:

- When you copy files from DOS to UNIX, RCP converts all file and directory names to lowercase characters and removes the DOS drive specifiers before sending the names to the remote host.
- When you copy files from UNIX to DOS, RCP prompts you for a new filename when a UNIX file or directory name is an invalid DOS file or directory name. If you specify the -I option when starting RCP, RCP does not copy files with invalid DOS file or directory names.

### Transferring Files

You can copy one or more files or directories from your workstation to a remote host by using the RCP command in the following format:

>     RCP -R [-A | -B] [-O] [-I] source [user@] remote_host=destination

You can copy one or more files or directories from the remote host to your workstation by using the RCP command in the following format:

>     RCP -R [-A | -B] [-O] [-I] [user@] remote_host=source destination

The following table describes the RCP command-line options and parameters.

#### RCP Options and Parameters

Options and Parameters | Description -A | This option forces RCP to transfer all files as text (ASCII) files. RCP adds carriage-return and line-feed characters to each line in UNIX files; RCP adds a carriage return only to lines in DOS files. If the source file includes embedded null bytes and you do not specify the -B option, RCP assumes the source file is a binary file and does not translate any EOL characters in the file.
-B | This option forces RCP to transfer all files as binary files. RCP does not add carriage-return or line-feed characters to binary files. This option is ideal when you are transferring binary files with a significant amount of embedded text or when you are backing up files that you use only on your workstation. This option can significantly improve RCP's file transfer performance.
-I | This option prevents RCP from copying remote host files that have invalid DOS filenames.
-O | This option prevents RCP from copying files with file extensions .OBJ, .O, .LIB, .EXE, and .COM.
-R | This option copies a directory recursively. When you use this option, you must specify destination as a directory. If you omit this option, RCP copies only the files in the directory, not the subdirectories and their files.
source | This parameter names one or more files or directories that you want to copy. You can specify source as a full or partial pathname. You can include wildcard characters (* and ?) in source.
user@ | This parameter names another user's account to which you have access. Include the @ character immediately after the account name (no spaces).
remote_host= | This parameter names the remote host. Include an equal sign (=) immediately after the name of the remote host.
destination | This parameter names the destination file or directory. If source is a file, destination can be a file or a directory. If source is two or more files or one or more directories, you must specify a directory for destination. If you specify destination as ".", RCP saves the file without changing the filename.

The following examples show how to use the RCP utility to copy files from your workstation to a remote host.

You can copy the SALES.RPT file to the current directory on a remote UNIX host (finance) and rename the file report.txt by typing the following command:

>     RCP SALES.RPT finance=report.txt <Enter>

You can give the new file the same name as the source file by typing one of the following commands:

>     RCP SALES.RPT finance=. <Enter>RCP SALES.RPT finance=SALES.RPT <Enter>

You can copy the SALES.RPT file to another user's (Evelyn's) home directory on a remote UNIX host (finance) and rename the file to report.txt by typing the following command:

>     RCP SALES.RPT evelyn@finance=report.txt <Enter>

You can copy the contents of the C:\REPORTS directory on your workstation recursively to the /x/ed/reports directory on a remote UNIX host (finance) by typing the following command:

>     RCP -R C:\REPORTS\*.* finance=/x/ed/reports <Enter>

The following examples show how to use the RCP utility to copy files from a remote host to your workstation.

You can copy the /x/ed/report1.txt file from a remote UNIX host (finance) to an existing directory (REPORTS) on your workstation and rename the file REPORT1.DOC by typing the following command:

>     RCP finance=/x/ed/report1.txt \REPORTS\REPORT1.DOC <Enter>

You can copy the contents of a directory (/x/evelyn/reports/) recursively from a remote UNIX host (finance) to a directory (\REPORTS) on your workstation by typing the following command:

>     RCP -R finance=/x/evelyn/reports/* \REPORTS <Enter>

You can copy all directories and files recursively from a user's (Carlyle's) home directory on a remote UNIX host (finance) to a directory (\REPORTS) on your workstation by typing the following command:

>     RCP -R carlyle@finance=* \REPORTS <Enter>

### Backing Up and Restoring Files

RCP enables you to back up your workstation files to a remote host, then restore them on your workstation. You can perform these backup tasks with RCP:

You can back up all files and directories from the C: drive on your workstation to a directory on a remote UNIX host (finance) by using the RCP command in the following format:

>     RCP -R -B C:\*.* finance=/x/yourname/backup

You can include the binary file transfer mode (-B) when backing up all files.

You can restore all backed up files and directories from a remote UNIX host (finance) to the C: drive on your workstation by using the RCP command in the following format:

>     RCP -R -B finance=/x/yourname/backup/* C:\

Be sure to include the binary-mode option (-B) if you originally backed up the files in binary mode.

### Stopping a File Transfer

You can stop a file transfer before it has concluded by pressing Ctrl+C or Ctrl+Break. After RCP stops, you might need to delete partially copied files from your workstation or the remote host.

Note: To abort a file transfer before completion, you must have started your workstation with BREAK ON set in your workstation LANWP.BAT.

### Transferring Files with the TFTP Utility

The Trivial File Transport program (TFTP) transfers files between your workstation and a remote host running a TFTP server program. TFTP does not require a password.

Before you can transfer a file to a remote host, a destination file of the same name must exist and it must have universal ("other") write permission.

You can include TFTP in a script file to update an existing file periodically.

### Using the TFTP Command

You can copy a file from your workstation to a remote host by using the TFTP command in the following format:

>     TFTP [-B] [-D] [-P port_number] [-V] source remote_host=destination

You can copy a file from a remote host to your workstation by using the TFTP command in the following format:

>     TFTP [-B] [-D] [-P port_number] [-V] remote_host=source destination

### Command-Line Options and Parameters

The following table describes the TFTP command-line options and parameters.

#### TFTP Options and Parameters

Options and Parameters | Description -B | This option enables 8-bit binary transfer mode. You use this mode when transferring binary files. If you do not specify this option, the transfer mode is ASCII. When transferring files between DOS and non-DOS systems, you might need to convert the end-of-line characters with the ASCII mode. (Do not include the -B option.)
-D | This option enables debugging mode. When the debugging mode is on, TFTP displays each command sent to the remote host.
-P port_number | This option and parameter selects an alternate port for establishing a TFTP connection with the remote server. The standard TFTP port number is 69.
-V | This option enables VERBOSE mode. When VERBOSE is on, TFTP displays all responses from the TFTP server.
source | This parameter names the file you want to copy. You must specify source as a full or partial path name if it is on your workstation but is not in the current directory. You must specify source as a full path name if it is on the remote host.
remote_host | This parameter names the remote host. You must include an equals sign (=) immediately after remote_host.
destination | This parameter names the file that TFTP overwrites when you copy files. You must specify destination as a full path name if the directory to which you are copying source is not the current directory. If you omit destination and source on your workstation, TFTP copies source to the current directory on remote_host under the same name. If you omit destination and source on the remote host, TFTP copies the file to the current directory on your workstation with the same name.

### TFTP Examples

The following examples show how you can copy files using TFTP.

You can copy the MARCH\ACCOUNTS.TXT file from your workstation to the /x/march directory on a remote UNIX host (sales) by typing the following command:

>     C:> TFTP MARCH\ACCOUNTS.TXT sales=/x/march/accounts.txt <Enter>

The destination directory (/x/march) must exist on the remote host and the destination file (accounts.txt) must exist in /x/march and have universal ("other") write permissions.

You can copy the /february/accounts.txt file from a remote UNIX host (sales) to the current directory on your workstation by typing the following command:

>     C:> TFTP sales=/february/accounts.txt
>     <Enter>

You can redirect the contents of the /february/accounts.txt file to your screen by typing either of the following commands:

>     C:> TFTP sales=/february/accounts.txt
>     - <Enter>

>     C:> TFTP sales=/february/accounts.txt - | MORE<Enter>

Top Previous: Emulating a Remote Terminal Next: Printing Files on Remote Printers