Starting and Running Your First Program on a Mainframe - HedgeDoc
<center> Starting and Running Your First Program on a Mainframe === *Written by [JDC]( Published 2021-06-01 on the [Monadical blog](* </center> In a [previous article](, I presented a collection of resources for learning COBOL and running COBOL programs on Linux. However, most COBOL programs actually run on mainframes, so to work with COBOL properly, you need to be able to operate a mainframe. Mainframes are infamous for being really expensive and inaccessible. On a budget, a mainframe will typically set you back several thousand [dollars]( And even if you buy one at auction [like this guy did](, you’ll need a lot of room to host it. Enter Hercules Hyperion: an open source software implementation of the mainframe System/370 and ESA/390 architectures, in addition to the latest 64-bit z/Architecture. Hercules is a free emulator that runs on Linux, Windows, Solaris, FreeBSD, and Mac OS X. In this tutorial, I’ll walk you through installing Hercules and MVS 3.8j Tur(n)key 4- ("TK4-"), a ready-to-use OS/VS2 MVS 3.8j system built specifically to run under the Hercules System/370. Hercules will allow you to learn how to operate a mainframe and run programs. Let’s get started! ![mainframes]( ## Installing Hercules The Hercules project is hosted on [github]( and you can find its documentation and installation instructions [here]( You can follow the instructions according to your operating system to compile Hercules, or install it from your Linux distribution package manager. In this tutorial, I’ll be using Ubuntu 20.04. Here’s how to install Hercules on Ubuntu: ```bash sudo apt-get update -y sudo apt-get install -y hercules ``` ## Getting and installing MVS on the operating system Hercules is an emulator, so you need to have a mainframe operating system that runs on Hercules. Fortunately, for this there's [TK4]( TK4 can be downloaded and is a Hercules-compatible version of the [MVS]( operating system. Go to the site and download the file `` (this is the latest distribution at the time of this writing). Once you get the file, create a directory you can easily locate and unzip the file inside it. ## Installing a 3270 terminal emulator The communication with the mainframe occurs via a terminal, so you need to install an [IBM 3270 terminal emulator]( In Ubuntu, this can be installed as follows: ```bash sudo apt-get update -y sudo apt-get install -y x3270 ``` ## Logging in into the mainframe Once the file `` is unzipped, it’s best to move the whole directory to `tk4` for easier access: ```bash mv tk4-_v1.00_current/ tk4/ cd tk4/ ``` It’s recommended to set console mode to get feedback in the terminal: ```bash cd unattended/ ./set_console_mode ``` Now you can start MVS: ```bash cd tk4/ ./mvs ``` After this command, the mainframe will boot. ![mainframe boot]( You can change the emulator view by pressing `ESC`. ![mainframe emulator]( At this point, you need to start your x3270 emulator and connect it to localhost port 3270. ![mainframe emulator]( Allow some time to boot with that image and hit the `ENTER` key. You will see this screen: ![mainframe emulator]( After this, input your username `herc01`. (There are other default users, but this guide will be using `herc01`, which has access privileges--for other users, check the manual You will be prompted to enter a password. ![mainframe emulator]( ![mainframe emulator]( For this user, `herc01`, the current password is `CUL8TR`. Enter the password and hit `ENTER`. ![mainframe emulator]( Hit `ENTER` again. ![mainframe emulator]( And after one final `ENTER`, you will be logged in to the mainframe emulator running MVS! ![mainframe emulator Hercules]( If you get lost, try this video from moshix (one of the [recommended resources]( from my last article). <center> <iframe width="560" height="315" src="" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </center> ## Exploring MVS Once logged in, you can start moving on the mainframe. Input number four `4` and press `ENTER` to see the process QUEUE. Now go ahead and explore on your own. To go back, use the function key 3 `F3`. ![mainframe]( You can see your terminal session listed. Again, to go back, use `F3`. ## Stopping the mainframe Once you’ve finished exploring, you’ll need to stop the mainframe. To stop the mainframe, go back to your terminal running `./mvs` and hit `ESC` to get back to the registers and devices view (if you're not already there). ![mainframe]( Hit the letter `P` to stop. CPP00 will change to CPP00 STOPPED. Then hit `W` for PWR and confirm with `Y` yes. That’s it! You just started a mainframe, ran a monitoring program, and stopped and powered off the mainframe. It’s recommended to correctly power off the mainframe to prevent any issues the next time you use it. In my next article, I’ll explain how to run a COBOL script on the mainframe. Stay tuned. --- <center> <img src="" style="height: 80px"/><br/> | Full-Stack Consultancy *We build software that outlasts us* </center>

Recent posts:

Back to top