Setup FTP from Mainframe to Non-Mainframe –Method II using Bat file

Here is another method with which you can transfer files from Mainframe to a windows Machine. To use this method you need to have a .Bat file and a file with list of files need to be transferred and valid Mainframe credentials.

You could also read other methods I’ve written about FTP’ing files from IBM Mainframe to Windows. These methods are easy to use and utilizes the free resources available in IBM Mainframe as well as Windows/free wares.

1. Simple FTP with Windows Bat file –

2. Setup FTP with Filezilla server.

3. Setup FTP with IIS (Internet Information Service) FTP server.


Copy the contents of below table and save it as script.txt. You can save anywhere you want, I saved it on C:\temp1 folder. Change my_mainframe_userid and my_mainframe_password to your mainframe user id and password. By default the your HLQ (High level qualifier) will be your mainframe id, so whatever DD names you mention in the script file will have HLQ (High level Qualifier) padded, e.g HLQ.DDS1764.PGMG.CBL(ASCEBCB1) ,

To avoid this, we issue  cd ..    . Update the DD names with your list of data set names, you can either use PDS member names, a PS or Compressed (xmited) PDS or everything. there is no limit for the number of files, but keep in mind that this could eat a lot of bandwidth, followed by the destination file. Save this file as script.txt in your windows machine.

cd ..
get “DDS1764.PGMG.CBL(ASCEBCB1)”  “C:\temp101.txt”
get “DDS1764.PGMG.CBL(ASCED)”  “C:\temp102.txt”
get “DDS1764.PGMG.CBL(ASMLNK1)”  “C:\temp103.txt”
get “DDS1764.PGMG.CBL(COB18DIG)”  “C:\temp104.txt”
get “DDS1764.PGMG.CBL(DIVZERO)”  “C:\temp105.txt”

Copy the contents of below table and save it as batchftp.bat .   Before oyu save the file, change my_mainframe_ip  to your mainframe host ip for name. when you save the file from Microsoft notepad, make sure you choose file name: batchftp.bat and Save as type: All Files (*.*) .

echo off
echo Batch FTP From Mainframe to Windows
echo   ***** Created by Shibu Thannikkunnath
echo   *****
echo   *****
ftp -s:script.txt my_mainframe_ip


Make sure you keep both the script.txt as well as the batchftp.bat file in the same folder. Now double click on the batchftp.bat to start download.  Once the script finished you can see all the transferred files in the folder mentioned in script.txt.



Try the script, let me know if you have any questions. If you think this tutorial helped you, don’t forget to like my facebook page, rate or share.  and support me by watching the below video (Ad)



3 thoughts on “Setup FTP from Mainframe to Non-Mainframe –Method II using Bat file

  1. As you said, it is taking the HLQ and adds this behind the dataset name mentione. because of this, it throws an error- dataset not found.
    even usinf cd.. it is taking the HLQ.
    how to remove that before the dataset name ?

  2. I just wanted to know

    –ftp -s:script.txt my_mainframe_ip–

    if there is any error occured in while processing the commands in the script.txt, how’d i come to know that exact message.

Leave a Reply to enrico Cancel reply

Your email address will not be published. Required fields are marked *

seventeen − 2 =