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 - 4083 days ago
Last viewed on: 29 Mar 2024 (7949 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

(Sign in to Post a Comment)
Posted by: Viking
Premium member *
CA
Comment on: Updated FTPFILE CL Command
Posted: 12 years 2 months 19 days 16 hours 7 minutes ago

Yes please, that sounds useful!

Thanks.

Posted by: jmasak
Premium member *
Appleton, WI
Comment on: Updated FTPFILE CL Command
Posted: 12 years 2 months 17 days 14 hours 19 minutes ago

That is something I am interested in as well.  Jeff

Posted by: bdietz400
Premium member *
columbus, oh
Comment on: Updated FTPFILE CL Command
Posted: 12 years 2 months 11 days 15 hours 39 minutes ago

I'm interested in the code as well.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 2 months 10 days 21 hours 28 minutes ago

You should all have your link to the updated FTPFILE command's save file.

Posted by: Viking
Premium member *
CA
Comment on: Updated FTPFILE CL Command
Posted: 12 years 2 months 9 days 14 hours 31 minutes ago

Thanks Bob.  I downloaded it and now need to get it up to my i and get it set up.

Looking forward to testing it out!  Thanks again.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 2 months 5 days 19 hours 3 minutes ago
Edited: Tue, 24 Jan, 2012 at 13:56:11 (4448 days ago)

Just a note to let you know that I updated the FTPFILE command again. I corrected one or two bugs and added a Passive Mode parameter. You can pull it down from the link previously sent you to.

I've also changed the way Source Members are transferred. Previously FTPFILE used ASCII mode for SOURCE FILE FTP, now it uses EBCDIC mode--which is an AS/400-only hybrid version of BINARY that correctly transfers source files of different widths. BINARY and ASCII modes would "screw up" if (for example) the source file member on the originating system as 92 and the target system it was 112. The result would look like it was "word wrapped". Switching the transfer mode to EBCDIC when the file is a source file corrects this issue. Any database or source file should be transferred using EBCDIC instead of ASCII or BINARY. EBCDIC is the default for source file members.

Lastly, when transferring source members, if the source member does NOT exist on the remote (target) system, during a SEND (PUT) command, the member is added and the text and SEU type of the member on the local system is used to add the member. This solves the issue when sending source to a new system and that source is created with blank SRCTYPE and TEXT values.

Posted by: mmiller
Premium member *
Comment on: Updated FTPFILE CL Command
Posted: 12 years 1 months 27 days 19 hours ago

I could use this as well

 

Thanks

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 1 months 26 days 22 hours 12 minutes ago
Edited: Tue, 31 Jan, 2012 at 11:09:29 (4441 days ago)

THE LATEST UPDATE TO FTPFILE HAS BEEN POSTED.

It includes the following updates/fixes:

  • Automatic EBCDIC mode for source files even when using *ALL or a generic form.
  • Better logging when using RCMD
  • ALL NEW: FTPRCMD to run only remote commands (see below)

NEW! - FTPRCMD (Use FTP RCMD to run remote command)

If you do not have REXEC working between your IBM i servers, you can use the FTP rcmd statement to run commands on other boxes. This requires that you setup an FTP !--script-- ahead of time, or perform an interactive FTP session.

The new FTPRCMD CL command accepts 1 to 3 CL commands to run on a remote IBM i system. There are 3 "rcmd" parameters. The first is RCMD and is a *CMD style parameter; meaning you can prompt the command inside the command prompter. The other 2 command parameters are RCMD2 and RCMD3 and do not support in-line CL prompting (this is a system restriction, not something I did). All three commands will run on the remote system.

This was created for users who do NOT yet have all IBM i v7r1 and later systems and need the capability of REXEC and the RUNRMTCMD between IBM i servers--RUNRMTCMD (that is REXEC) it does not work between IBM i servers until v7. Prior to v7 using RCMD inside an FTP session was the only generic solution. The new FTPRCMD allows anyone at v5r2 and later to run remote commands from the Command Entry display or within a CL program.

All commands and FTP responses are written to the local joblog.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 1 months 16 days 18 hours 14 minutes ago

New FTPRCMD CL command has been integrated into the FTPFILE package.

A new save file has been posted (see original message for download link). Thanks to MidrangeNews members who asked to have an advanced copy and provided their feedback.

Please note that when we introduce "Cozzi Utilities 2012" later this Spring, these two commands will be incorporated into it.

Posted by: clbirk
Premium member *
Comment on: Updated FTPFILE CL Command
Posted: 12 years 29 days 13 hours 38 minutes ago

o.k., I can download it from the link but how do we install this savf? Is it just a retore into the library that we choose or do we put it in qgpl and run some sort of install cl command or just what?

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 29 days 11 hours 4 minutes ago

The file inside the ZIP is a SAVF.

You need to FTP it up to your IBM i server and do a restore library to the library of your choice. The source is provided if you need to move it, but typically you can just restore the objects using RSTOBJ to any library you want.

Here's a link to an article I wrote on how to upload a SAVF file using FTP:

http://www.midrangenews.com/view?id=1217

Posted by: clbirk
Premium member *
Comment on: Updated FTPFILE CL Command
Posted: 12 years 27 days 17 hours 58 minutes ago

there is part of the confusion, the drop box link you have isn't a zip, it is the savf. Thanks for the link.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 27 days 8 hours 17 minutes ago

Oh yeah. You're right. Cool

Guess you gotta be a programmer and figure it out; as you did.

Posted by: clbirk
Premium member *
Comment on: Updated FTPFILE CL Command
Posted: 12 years 21 days 20 hours 5 minutes ago

Does FTPFILE really only work (or designed for), moving a file between i's? The reason I ask is that I don't see anything for logging in (so I assume the user has to be on both?) and the name to go to on the remote target, etc., appears to be qsys format files. Also I would assume you can't put it in remote ifs? No doubt it has a very useful purpose but I am simply asking these questions so I know its full potential for me.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Updated FTPFILE CL Command
Posted: 12 years 21 days 17 hours 31 minutes ago

You don't see the USER and PWD fields on the command prompter? They are there, but don't appear until you enter the target and local and/or remote file names. You can always use F10 to see them ahead of time.