• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Using FTP to Transfer Multiple Files Between Windows and the i5

    October 18, 2006 Hey, Joe

    Every day, I have to transfer a variable number of files from my Windows server to my AS/400. I need to FTP all the files in the same directory and each transferable file begins with the same prefix, ABCFILE (ABCFILE.2006.09.11.2, ABCFILE.2006.09.11.3, etc). Once I get the files to the AS/400, I’d like to combine them into one file that’s simply called ABCFILE. Got any ideas?

    –Mark

    I can tell you how to FTP multiple files at the same time, but I’m not too sure about the best method for combining them. Here’s what I’m thinking.

    For transferring multiple Windows files to an AS/400, I’m assuming that you’re transferring files from the Windows server to an i5, iSeries, or AS/400 (i.e., the Windows server is functioning as the FTP client and the AS/400 is functioning as the FTP server). Since it’s a scheduled transfer, I’m also assuming that you will want to automate the transfer. If you want to see some examples of how to set up an automated Windows-to-AS/400 FTP session, check out an earlier article I wrote called Automating FTP Transfers Between OS/400 and Windows. For this example, I’m modifying the FTP code in that article for transferring a single file from Windows to an AS/400 server, changing it to send out multiple files by using the FTP MPUT command.

    Here’s the FTP script that I would use to transfer your files from a Windows directory on the C: drive called HOLDOUT to a corresponding directory on the AS/400 Integrated File System (AS/400 IFS) called HOLDIN.

    OPEN SERVER_NAME
    USER_NAME (your AS/400 FTP user_name goes here)
    USER_PASSWORD (the password for your AS/400 FTP user goes here)
    BIN
    CD /HOLDIN
    LCD C:HOLDOUT
    MPUT ABCFILE*
    QUIT
    

    I would save this FTP script as a Windows text file called ftpinput.scr, and I would also store it in my Windows C:HOLDOUT directory. I would then create a batch file called as400ftp.bat on my Windows server that contains the following command:

    ftp -i -s:C:holdoutftpinput.scr

    When I execute the as400ftp.bat file either manually or through the Windows scheduler, the file will do the following things.

    • Start an FTP session on my target AS/400 by signing on as the user designated in the USER_NAME literal and using the password designated as USER_PASSWORD.
    • Use the MPUT command to transfer all the files that start with the literal ‘ABCFILE’ in the C:HOLDIN directory on my Windows machines.

    For an explanation of what each individual FTP command does in this script, see the Automated Windows to AS/400 transfer article. I made the following changes to my original script to meet your needs. Here’s where the differences are.

    First, instead of using an FTP PUT command to transfer a single file, I used the FTP MPUT command to transfer multiple files that start with the same literal. An asterix character (*) in an MPUT command is a wildcard character that tells the server to transfer all files that begin with that literal (ABCFILE, in your case).

    The second change occurs in the batch command that executes this FTP script. In the original script, I only used the -s parameter in my FTP statement to designate the name of the text file that contains the FTP commands that should be run. This time, I added the -i parameter to my FTP statement, which tells FTP to turn off any interactive messages that occur during a file transfer. If you don’t turn off the prompting when you’re sending multiple files, FTP will display the following prompt each time the MPUT statement goes to transfer another file.

    Are you sure you want this file (y/n)?

    Not only does this get really annoying after the first transfer, it prevents you from running this batch file in unattended mode. So using this script would allow you to easily transfer all your files to your i5 box. I tested this FTP script and batch file on a Windows XP machine, and they worked great for transferring files to an i5/OS V5R3 machine.

    Unfortunately, I don’t have any techniques for combining your individually dated ABCFILEs into one larger ABCFILE on your i5 box. But I do have a suggestion. Perhaps you can combine your files before transferring them to your AS/400, and then just transfer that one ABCFILE up to your AS/400 instead of transferring multiple files. Maybe you could write a Windows program or script to combine the files. I also played a little bit with using the old DOS XCOPY command to combine the files but I had limited success. If you come up with a technique for combining your files into one file, you could easily modify your script and batch files to do the following two things:

    1.  You could insert the code for combining the files into the as400ftp.bat file so that it creates the single unified ABCFILE before the FTP transfer begins.

    2.  You could then modify your FTP code to use a PUT statement for transferring the single file instead of using the MPUT statement for transferring your multiple ABCFILE.* files. The new FTP script for the single unified transfer might look something like this:

    OPEN SERVER_NAME
    USER_NAME (your AS/400 FTP user_name goes here)
    USER_PASSWORD (the password for your AS/400 FTP user goes here)
    BIN
    CD /HOLDIN
    LCD C:HOLDOUT
    PUT ABCFILE
    QUIT
    

    I hope this helps. Thanks for writing.

    –Joe

    RELATED STORY

    Automating FTP Transfers Between OS/400 and Windows

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Raz-Lee Security

    Start your Road to Zero Trust!

    Firewall Network security, controlling Exit Points, Open DB’s and SSH. Rule Wizards and graphical BI.

    Request Demo

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Canvas Systems:  We build and deliver custom iSeries rental solutions
    Integrated Print Solutions:  Print AFP/IPDS documents to any network printer
    COMMON:  Join us at the Spring 2007 conference, April 29 – May 3, in Anaheim, California

    Rimini Street Hires SAP Execs as TomorrowNow Expands Operations Will New Rebates on Standard Edition i5s Boost Sales?

    Leave a Reply Cancel reply

Volume 6, Number 38 -- October 18, 2006
THIS ISSUE SPONSORED BY:

ProData Computer Services
Advanced Systems Concepts
Asymex

Table of Contents

  • The SPACE Function Takes Up a Lot of Space
  • Declare the BINARY Data Type Using DDS
  • Using FTP to Transfer Multiple Files Between Windows and the i5

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle