Midrange News for the IBM i Community


Send or Receive a File using FTP on IBM i or iSeries Published by: Bob Cozzi on 05 May 2012 view comments

FTPFILE - Send/Receive File Using FTP

This command is part of the COZTOOLS software package for IBM i system. Visit www.cozTools.com for more information on how to order a copy for your system.

The FTPFILE command allows you to send or receive a file with FTP using a CL command interface--bypassing the need to create and use FTP script.

Command Parameters

RMTSYS - The remote system name or IP address of a report FTP server. This may be any type of FTP server. We even use this command to pull down PTFs from the IBM service and support site (prior to v7r1 when they made the SNDPTFORD command work the way it should).

PUTGET - A "switch" to indicate if you and sending (PUT) or receiving (GET). Specify *PUT to send a file and *GET to receive a file.

Local and Remote File Parameters

The LCLFILE, RMTFILE, LCLMBR and RMTMBR commands are used when either a PUT or GET is specified for the FTPFILE command. This means that when you are sending a file (i.e., PUT) the LCLFILE (local file) is sent to the RMTFILE (remote file). However, when you are receiving a file (i.e., GET) the LCLFILE is be received and the RMTFILE is being send to you. Be sure you understand these concepts or you may receive what you think are errors but are instead, simple conceptual misinterpretations.

LCLFILE - The name of the file on the local system. This can be either a qualified library/file name or the special value *STMF to indicate that local file resides on the IFS. When LCLFILE(*STMF) is specified, the LCLSTMF and RMTSTMF parameters are required.

LCLMBR - The name of the local file's member. The special value *FILE may be specified to indicate that the member name is the same as the LCLFILE parameter. When transferring an entire file and all of its members, the special value LCLMBR(*ALL) may be specified. Be sure to use RMTMBR(*LCLMBR) when LCLMBR(*ALL) is specified.

RMTFILE - The name of the file on the remote system. This can be either a qualified file name or the special value *LCLFILE. The library portion of this parameter may be a valid library name or *LCLLIB to indicate that the library specified for the LCLFILE parameter is used.

RMTMBR - The name of the remote file's member. The special value *LCLMBR may be specified to indicate that the name specified on the LCLMBR parameter is used. In addition, the special values *LCLFILE and *RMTFILE may be specified.

OBJTYPE - The default *AUTO is normally good enough, however if you are receiving a file and that file does not exist on the local system, there may be an issue in creating it. For example, if you are pulling down (i.e., GET) a save file from another system, and that save file does NOT exist on the local system, you should specify OBJTYPE(*SAVF) to force the FTP engine to use the proper settings to transfer a save file correctly. When sending an object, then OBJTYPE(*AUTO) is usually correct.

REPLACE - In many cases FTP will automatically replace the target file. This parameter insures that the FTP (Replace option (yes that syntax is correct) is added to the transfer statement in the generated FTP script.

LCLSTMF - The name of the local IFS file that is being sent or received. This parameter is valid only when LCLFILE(*STMF) is specified.

RMTSTMF - The name of the file on the remote system that is being sent or received. This parameter is only valid when LCLFILE(*STMF) is specified.

USER - The user profile to send to the remote system in order to start the FTP session.

PWD - The password for the user profile specified on the USER parameter. The special value PWD(*USERID) may be specified. When *USERID is specified, the user profile name specified on the USER parameter is also sent as the password.

MODE - The mode parameter controls the translation of the data in the file being transferred. The default, MODE(*AUTO) is often good enough, however other modes are support and may be specified whenever the kind of data being sent could be ambiguous to the FTP engine. The valid choices for the MODE parameter are:

  • *AUTO - Try to figure out the best choice.
  • *ASCII / *TEXT - Transfer in "plain ASCII" mode.
  • *BINARY / *IMAGE - Transfer "as is" not character translation.
  • *EBCDIC - Sending between IBM i systems when the file is NOT an IFS file.

PASV - Passive mode FTP setting. While most FTP transfers today use Passive Mode, some routers do not allow passive mode. This parameter may be used to switch to ACTIVE mode. The valid choices for the PASV parameter are:

  • *PASV - Use passive mode.
  • *EPSV - Use extended passive mode.
  • *AUTO - Use the default setting for the IBM i system.
  • *NONE - Do not send a PASV command to the FTP processor.

SRCFILE - The name of the source file that will receive the FTP script generated by the FTPFILE command. The default is SRCFILE(QTEMP/QFTPSRC) and if it doesn't exist is created using: CRTSRCPF FILE(QTEMP/QFTPSRC) RCDLEN(112)

SRCMBR - The name of the source file member into which the FTP script is stored. The default is SRCMBR(*LCLFILE) meaning the file name used on the LCLFILE parameter is used as the source member name in QFTPSRC. Another option *GEN is used to cause the FTPFILE command to generate a member name using a sequencing scheme.

LOG - The name of the source file that will be used to receive the FTP log information. The FTP engine generates a lot of information into its log. This parameter allows the user to store that log information into a source file member for later review. Two special values are available for the LOG parameter:

  • * or *STDOUT - Write the FTP log to the screen
  • *NONE - Do not write the FTP log to the screen nor to a source file.
  • srcfile - Write the FTP log to the member specified on the LOGMBR parameter in this source file.

LOGMBR - The name of the source member that will receive the FTP log. The LOG parameter may be any name you wish, however 3 special values are supported in addition to a valid name:

  • *LCLMBR - Write the log to a member name that is the same as the member specified on the LCLMBR parameter.
  • *SRCMBR - Write the log to a member name that is the same as the member specified on the SRCMBR parameter.
  • *GEN  - Generate a log member name using a sequencing scheme.

DSPLOG - After the FTP process is complete, the FTP log may be displayed to the end-user. The DSPPFM command or similar is used to show the log to the end-user. Note if LOG(*NONE) is specified this parameter will not display anything. The default is DSPLOG(*NO)

RCMD - After the FTP transfer is complete, specify an optional remote CL command to run on the remote system. For example, if you are transferring a save file to a remote IBM i system, use this parameter to specify a RSTOBJ command that restores the save file after it has been transferred.

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS