Previous Page Contents Page Next Page

3.6 Transferring Files

The following command is used to specify a particular user-defined transfer request:

sna400ft transfer [filename] [ general options] [transfer options] [transfer_request_string | -x transfer_request_filename [transfer_request_parameters ]]

This command can be used with the general options described in General File Transfer Command Options, or the transfer options described below. File transfer messages are described in File Transfer Messages.

Do not overwrite existing data in a member, or truncate lines. If this option is specified the file transfer program stops the transfer operation if the following conditions apply:

  • Data in an existing member is going to be overwritten by the transfer operation

  • Lines which are longer than a specified length are going to be truncated

Overwrite existing data in a member and truncate lines if necessary. If this option is specified, the file transfer program continues the transfer operation even if the following conditions apply:

  • Data in an existing member is going to be overwritten by the transfer operation

  • Lines which are longer than a specified length are going to be truncated

These options should be used if you are controlling file transfer from a script. If none of these options are specified, the file transfer program warns you if data in an existing member is going to be overwritten, or if lines will be truncated, and prompts you to specify whether they wish to continue with the file transfer.

transfer_request_string

Specifies the type of AS/400 transfer request (described in the section, AS/400 Transfer Requests). It can be one of the following:

SELECT

Selects a particular field or fields from the records in a file according to various criteria, and transfers this data from the AS/400 to the local machine

REPLACE

Transfers data from a local machine to the AS/400. It can create files (in which case the file format has to be specified), members within files, or both. Alternatively the data transferred can replace existing members.

EXTRACT TABLES

Lists the files contained in a particular library.

EXTRACT COLUMNS

Lists the field definitions in a specified file.

OPTIONS

Specifies particular options.

If the first word in the transfer request string is not SELECT, EXTRACT , REPLACE, or OPTIONS, the file transfer program interprets it as the name (and path) of a file containing the transfer request string. If this file does not exist there is an error.

A detailed description of transfer requests and their syntax can be found in the PC Support/400 API Reference.

transfer_request_filename

Specifies a file that contains the transfer request string. A transfer request file may contain substitution symbols %1, %2, and so on. Each word in the command line which follows the transfer request file name (the transfer_request_parameters) replaces a substitution symbol. The file contents, combined with the substitutions, make up the transfer request string.

transfer_request_parameters

Specifies values to replace the substitution symbols used in the transfer request file. If there are not enough words to satisfy the number of symbols, you will be prompted for them. The file contents, combined with the substitutions, make up the transfer request string.

3.6.1 Example of a File Transfer Request

The following example illustrates how a file could be used to provide the transfer request string for a transfer command.

  1. A transfer file called selreq contains the following transfer request:

    SELECT %1 FROM QGPL/%2

    This transfer request asks the AS/400 to send data from the field named by the parameter %1 from the file named by the parameter %2 in subdirectory QGPL. Parameters %1 and %2 must be supplied at the command line.

  2. The user types the following at the command line:

    sna400ft transfer selreq flda filea(membera)

    The first substitution symbol, %1, is replaced by the word flda, and the second substitution symbol, %2, is replaced by the words filea(membera).

  3. The file transfer program sends the following transfer request to the host:

    SELECT flda FROM QGPL/filea(membera)

    This transfer request asks the AS/400 to send data from the field flda in the member membera in a file called filea in the subdirectory QGPL.

  4. If a description file is specified with the option, and the first word of the transfer request string is REPLACE followed by an asterisk, the asterisk is replaced with the list of field names from the description file. If the REPLACE word is not followed by an asterisk, the words between REPLACE and INTO are interpreted as field names.

3.6.2 Output from File Transfer Commands

If a SELECT, EXTRACT, or OPTIONS transfer request is used, any data returned from the AS/400 is directed to stdout, and if the option is specified, a description file is created. (For more information about description files, see Description Files.) If the option is specified without a description file name, a default name of default.fdf is created. Any error messages from the AS/400 are sent to stderr .

Previous Page Contents Page Top of Page Next page