<center> Starting and Running Your First Program on a Mainframe === *Written by [JDC](https://twitter.com/jdcaballerov). Published 2021-06-01 on the [Monadical blog](https://monadical.com/blog.html).* </center> In a [previous article](https://monadical.com/posts/cobol.html), 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](https://www.quora.com/How-much-does-an-IBM-mainframe-cost). And even if you buy one at auction [like this guy did](https://www.youtube.com/watch?v=45X4VP8CGtk), 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](https://docs.monadical.com/uploads/upload_8b6e81569ccb5a93c4a4d1ce57a2dc49.png) ## Installing Hercules The Hercules project is hosted on [github](https://github.com/sdl-hercules-390/hyperion) and you can find its documentation and installation instructions [here](https://sdl-hercules-390.github.io/html/). 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](http://wotho.ethz.ch/tk4-/). TK4 can be downloaded and is a Hercules-compatible version of the [MVS](https://en.wikipedia.org/wiki/MVS) operating system. Go to the site and download the file `tk4-_v1.00_current.zip` (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](https://en.wikipedia.org/wiki/IBM_3270). 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 `tk4-v_1.00.current.zip` 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](https://docs.monadical.com/uploads/upload_820dd24c104ebbf2f39bb2c0192bd133.png) You can change the emulator view by pressing `ESC`. ![mainframe emulator](https://docs.monadical.com/uploads/upload_96d66dcd1c0983e54947a786d3d3ff80.png) At this point, you need to start your x3270 emulator and connect it to localhost port 3270. ![mainframe emulator](https://docs.monadical.com/uploads/upload_21b4414e1f59a5e7001cfd0bb3307bbd.png) Allow some time to boot with that image and hit the `ENTER` key. You will see this screen: ![mainframe emulator](https://docs.monadical.com/uploads/upload_448a2e99dee90a310dc9e6c57416fd44.png) 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 http://wotho.ethz.ch/tk4-/MVS_TK4-_v1.00_Users_Manual.pdf.) You will be prompted to enter a password. ![mainframe emulator](https://docs.monadical.com/uploads/upload_3ec126719ca34878f3de9142925401ef.png) ![mainframe emulator](https://docs.monadical.com/uploads/upload_1e216aefd5ad4f5bc58540f9cd9f0fa7.png) For this user, `herc01`, the current password is `CUL8TR`. Enter the password and hit `ENTER`. ![mainframe emulator](https://docs.monadical.com/uploads/upload_1fedeb416f7ceabbfe4af85e8c28e306.png) Hit `ENTER` again. ![mainframe emulator](https://docs.monadical.com/uploads/upload_6bc9aeef375e5d8015f9cbcddc05b8d5.png) And after one final `ENTER`, you will be logged in to the mainframe emulator running MVS! ![mainframe emulator Hercules](https://docs.monadical.com/uploads/upload_54f01a53c13ecad14115f810a921db1f.png) If you get lost, try this video from moshix (one of the [recommended resources](https://monadical.com/posts/cobol.html#Resources) from my last article). <center> <iframe width="560" height="315" src="https://www.youtube.com/embed/UOL0HtlXVKM" 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](https://docs.monadical.com/uploads/upload_4106c911ac1cfd93d7109970ba051b65.png) 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](https://docs.monadical.com/uploads/upload_15d81759fe56414d9c178c100a207c4c.png) 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="https://monadical.com/static/logo-black.png" style="height: 80px"/><br/> Monadical.com | Full-Stack Consultancy *We build software that outlasts us* </center>
- A pattern for strategy backtracking using Python generators
- How to mint NFTs using Solana’s mobile wallet adapter
- How to build a modular arithmetic library in Python
- Ramping up on Solana Phone: Crypto for mobile
- View more posts...
Back to top