Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Updated FTPFILE CL Command
has no ratings.
Published: 10 Jan 2012
Revised: 23 Jan 2013 - 2185 days ago
Last viewed on: 16 Jan 2019 (6072 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Updated FTPFILE CL Command Published by: Bob Cozzi on 10 Jan 2012 view comments(15)

I've made a few updates to the popular FTPFILE (formerly FTPSNDFILE) CL command.

You can download it from here. It is a SAVF that needs to be FTP'd up to your system and contains the most current version (updated 10 Feb 2012)

The updates include the following:

  1. Send and Receive Files (i.e., PUT and GET support)
  2. In addition to database files, IFS files may be sent and received
  3. You can specify a POST-Transfer CL Command to run using RCMD
  4. Joblog messages reflect more useful FTP-related information
  5. Defaults to MODE(EBCDIC) when FTP'ing source file members.
  6. Source File Member SEU Type and Text are inserted for "new" members sent to remote.
  7. Database and source files are transferred using the STRUCT (record) statement.
  8. Separate FTPRCMD (run CL command via FTP's RCMD statement) command.

NOTE: I'm getting email asking about dropbox which I use to store the FTPFILE download. I previously wrote an article on the subject. Dropbox is a free service and widely used. Check out my article here for more information on Dropbox.

Send or Receive Files

You can use the PUTGET parameter to specify PUTGET(*GET | *PUT). The former version of the command only sent database files. This new version will send (i.e., PUT) and receive (i.e., GET) database files or IFS files.

Database and IFS Files May Be Transferred

As mentioned, in addition to traditional CPF/OS/400/i5/i database files, the user may specify LCLFILE(*STMF) and then specify the IFS file to send and or receive using the LCLSTMF and RMTSTMF parameters. As always, full generic capabilities for both DB2 files and IFS files is supported.

Post-Transfer CL Command to Run

The RCMD parameter accepts a CL command that may be run on the remote server after the transfer completes (or fails to complete). Currently this command is always run by adding it to the FTP script that is generated. It is run using the QUOTE RCMD commands in FTP. The parameter supports embedded prompting similar to the CMD parameter of the SBMJOB command.

More Favorable Joblog Messages

Previously several diagnostic and completion messages along with ad hoc messages were written to the joblog when running the FTPFILE command. Now, those message are "swallowed". In place of them, more FTP-worthy message are generated including the following:

  • Connected to host YYYYY at address xxx.xxx.xxx.xxx
  • 150 Sending File to...
  • xxx bytes trasnferred...
  • The RCMD (if applicable)
  • 250 Remote Command xxxxxxx successful. (If applicable)

Example

I use FTPFILE all the time to send or receive save files from other IBM i systems. Now with the new RCMD parameter, I can also restore from that save file immediately after the transfer without the need to sign on. Here's an example:

 

FTPFILE RMTSYS(MY720) PUTGET(*PUT) LCLFILE(QGPL/MYSAVF) USER(QPGMR) PWD(ROSEBUD)
     RCMD(RSTLIB SAVLIB(COZTOOLS) DEV(*SAVF) SAVF(QGPL/MYSAVF)      
         MBROPT(*ALL) ALWOBJDIF(*ALL) FRCOBJCVN(*YES *RQD))         

 In this example, the save file named MYSAVF in QGPL is sent to the remote MY720 system. Then, after the transfer finishes, the RSTLIB command is run to restore the COZTOOLS library onto the remote system.

Availability

The FTPFILE command definition and its RPGIV command processing program source code is available on request. Simple post a message/comment in response to this article and I'll send you a note with information on where you can download the code.

 And no, if you send me an email asking me for the link or the source code, I will not reply to it.

FTPRCMD

The FTPRCMD CL command, allows Users to run CL commands on remote IBM i servers without the need for REXEC to be started. Using FTP's rcmd statement, the FTPRCMD runs virtually any "batch" compatible CL command on the remote system. If you don't have REXEC which doesn't run CL until at least v7r1, or you're using some goofy Telnet trick, this new command might simplify things for you.

FTPRCMD is included in the FTPFILE save file/library.

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

COMMENTS