Web Slinging Mainframe
Okay, it's rodeo time here in Houston, Texas, or perhaps it's because my child likes Spider-girl, and I'm too old to enjoy comic heroes. So forgive me on the title of this article as Web Spiders crawl the web to add content for their search directories, and they just might find a mainframe hosting a web page these days. Here at BMC, we use a Linux on the mainframe to provide support to our R&D users by hosting a intranet web based portal that they can use to manage their own z/Linuxes.
Below is an example of how open source can be implemented on a mainframe by showing an example of a Linux webserver setup that might create an intranet web portal interface for MVS users to submit requests for dataset restore. Of course, this will be kept brief for demonstration purposes. Keep in mind that more coding could be needed for security and other installation needs. In future posts, I can show how to handle that. Finally, I also ask for leeway in showing an example of how you might write an application bearing in mind that most people would not do it this way. So lets use this example for education value only.
On z/OS (MVS) you could use Unix System Services, the base IBM http server, and Websphere application server's J2EE to help create your portal. However, I will introduce you to open source products like Apache and PHP. This will enable you to engage the distributed people on technology that they are familiar with as well. Apache is an excellent open source webserver and is available as an installable package on the s390(31bit) and s390x(64bit) Linux distros. Of these Linuxes, a free downloadable distro is CentOS Linux, a version similar to Redhat, or you can use the commerical products like Redhat Enterprise or Novell SuSE SLES Linux for example.
If you are using a new z series Linux install, make sure that enough disk space is available. Typical installs are about 3GB,so a DASD 3390-mod6 with 6677 cylinders is recommended to provide enough free space for the Linux. If you are new to installing z/Linux, you can use Redhat's or SuSE's installation manuals for S390 Z series. I will also show an example of a z/Linux install in a future post. Now is a great time to get a few Linux friends involved.
During the install of the z/Linux, you can specify the configuration as a webserver or you can specifically request that all the related packages are installed. It is recommended that you also install the PHP packages and use this scripting language to write the web application. Specifically, you will need the php5 and php5-ftp package for this example to work. Once the Linux is installed and is brought back up, an Apache webserver is easy to setup in Linux. The default html web directory in SuSE SLES is /srv/www/htdocs unless you change this in the /etc/apache2 directory. If you write code then you might want to output (tail command) the /var/log/apache2/*error_log files if your application is having problems.
To activate the webserver issue these commands (SuSE SLES):
chkconfig apache2 on
service apache2 start
We will place in the html web directory a few files: Lets create a HTML form page with a submit key and a php script as the submit routine to write this to a file and ftp to MVS. MVS will then check to see if a updated request file is present and submit a JES2 dataset restore job for the user.
Lets remote desktop to the zLinux to create the files. If you are new to Linux, but familiar with windows, you can install an X client/server product like Hummingbird's exceed or open source types like http://sourceforge.net/projects/xming for your desktop. Then install putty http://www.putty.org/ for SSH connections. Before you connect to the Linux with putty SSH, check the Forward X11 option. Then connect to your z/Linux. Here you will be able to start a graphics user interface(GUI) to the Linux desktop known as KDE or GNOME (which ever was installed with z/Linux). To start KDE type "startkde". For GNOME, type "gnome-session". Of course if you have a Linux desktop you already have X server and you can follow the same for Forward X11 and SSH a connection. From there, you can navigate the menus to pull up a GEDIT or KEDIT editor to allow you to create these files in the HTML directory.
Brief form page, form.html:
<html><body><p>Submit
Dataset Restore Request to MVS </p>
<form method="POST" action="submitter.php">
<table> <tr><td>Dataset:</td><td><input
type="text" name="dataset"
size="44"></td></tr><tr><td>Userid:</td><td><input
type="text" name="username"
size="8"></td></tr><tr><td>Password:</td><td><input
type="password" name="password" size="8"></td></tr>
</table>
<input type="submit" value="Submit" name="submit">
<input type="submit" value="Cancel" name="cancel">
</form></body></html>
This above code will display a html form which the user supplies the requested dataset, a MVS userid, and password. The input type of password instead of text will hide the password while typing.
Submitter.php:
<?
#if not cancel then proceed
if (isset($_REQUEST['cancel'])) {
#issue error message
header("Location: http://".$_SERVER['HTTP_HOST']."/cancel.html");
exit;}
#get form values
$rdata = $_REQUEST['dataset'] ;
$user=$_REQUEST['username'];
$pass=$_REQUEST['password'];
#store request file
$rfile = "/tmp/reqfile.txt";
$fh = fopen($rfile, 'w');
$nl = "\n"; /* lets create the newline byte for the file */
$flag = "y"; /* this flag is to signal MVS to process */
$strdata = $flag . ' ' . $rdata . $nl;
fwrite($fh, $strdata);
fclose($fh);
#begin ftp process
$mvs="yourmvs.company.com";
$dest="mvs.request";
$conn = ftp_connect($mvs);
#login to ftp at mvs
ftp_login($conn, $user, $pass);
ftp_put($conn, $dest, $rfile, FTP_ASCII);
ftp_close($conn);
#give user confirmation
header("Location: http://".$_SERVER['HTTP_HOST']."/reqdone.html");
?>
As you can see from this code that if the requestor pressed the cancel button then he will get the cancel.html page. The values from the form are set to local variables and the dataset value is written to a request file on Linux along with a flag charactor for the routine on MVS to process this request. This routine then ftp's the temp file over to MVS and displays the confirmation html page. Keep in mind that this is a brief example and that this code can not handle multiple web user requests for restores and failures within the file and ftp operations. Also not shown are the two files "cancel.html" and "reqdone.html" that display a simple message. For more code examples and reference of PHP, refer to www.php.net Additionally, many references are available on the net about html form pages and table html tags.
For those that are already familiar with this side of the technology, I will pen the next post for the distributed folks to understand a little about z/OS (MVS) operating environment as this request gets picked up and processed by that system's batch job processing for the dataset restore request of this mainframe user.
_____
tags:


