MainframeSupports
tip week 21/2014:

It is more than seven years ago I wrote my first tip about FTP. This tip was about how you can use the FTP command from TSO. Most mainframe installations have not opened up to the outside world (security!). The result is that most FTP communication between the outside world and the mainframe uses a PC as the client and the mainframe as server.

When you need to transfer a file between your PC and the mainframe using FTP, you start FTP on your PC and connects to the mainframe. Most likely you use some fancy FTP-program with a nice dialogue where you can navigate around between PC files and mainframe datasets. There are a lot of such programs available, so in this tip I will instead show you a simple BAT file you can use for transferring a single file between your PC and the mainframe:

@echo off
c:
cd \ftp
set /p ftpcmd1=ftp-command
if "%ftpcmd1%"=="binary" set /p ftpcmd2=ftp-command
echo myuser >ftpcmds.txt
echo %ftpcmd1% >>ftpcmds.txt
if "%ftpcmd1%"=="binary" echo %ftpcmd2% >>ftpcmds.txt
ftp mainframe-ip-address <ftpcmds.txt >con:
pause

In the above BAT file you need to replace the text myuser by your TSO userid and the text mainframe-ip-address by the ip-address (or nickname) for the mainframe you need to communicate with. Maybe you also need to make changes to line two and three because you want to place the file ftpcmds.txt in another directory that actually exists on your PC. Please be aware that the command "echo myuser >ftpcmds.txt" adds a space to your userid. If you have problems logging on when running the BAT file then try to use "echo myuser>ftpcmds.txt".

When you execute the BAT-file it will ask you to enter a ftp-command. If you type binary it will ask you to enter a new ftp-command. This feature enables you to use the BAT file to transfer files without character conversion (for instance PDF files). As ftp command you can use "put from-PC-file to-mainframe-dataset" or "get from-mainframe-dataset to-PC-file". Remember to use apostrophes (') around datasetnames, or else they will be prefixed with your TSO-userid.

Finally the ftp transfer is carried out. It will detect that you have not entered any password and prompt you for it. When you have entered the correct password the tranfer is carried out. The finishing pause I have added because if you execute the BAT file as a shortcut from your desktop pause will make sure that any error messages issued from the ftp command does not disappear before you have pressed a key.

Previous tip in english        Forrige danske tip        Tip list