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.
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:
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.
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.
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.
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.
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:
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.
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.
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.
Yes please, that sounds useful!
Thanks.
That is something I am interested in as well. Jeff
I'm interested in the code as well.
You should all have your link to the updated FTPFILE command's save file.
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.
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.
I could use this as well
Thanks
It includes the following updates/fixes:
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.
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.
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?
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
there is part of the confusion, the drop box link you have isn't a zip, it is the savf. Thanks for the link.
Oh yeah. You're right.
Guess you gotta be a programmer and figure it out; as you did.
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.
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.