using perl on an as/400 / iseries
DESCRIPTION
Presented by David Mount Owner of Texas400 Computer Consulting See www.texas400.com for more on Perl on the iSeries / AS400. Using Perl on an AS/400 / iSeries. Reasons to Pay Attention. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/1.jpg)
Using Perl on an AS/400 / iSeries
Presented by David Mount– Owner of Texas400 Computer Consulting
See www.texas400.com for more on Perl on the
iSeries / AS400
![Page 2: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/2.jpg)
Reasons to Pay Attention
You may actually want to provide the public or your users with internet access to some of your data – PERL is an easy and FREE way to do this
PERL is a great way to learn about CGI programming as well at HTML and HTTP server
Someday, you may have the chance to port a PERL application to your iSeries
![Page 3: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/3.jpg)
Typical Computer User’s Understanding of AS/400 / iSeries
What’s an AS/400? What’s an iSeries? Old architecture that uses green screens Programs written in RPG Runs applications written 10 to 15 years ago Doesn’t belong in the same sentence as “internet” Upload data via PC Support or Client Access Really different from world of PC’s and internet Isolated from rest of world
![Page 4: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/4.jpg)
We have the opportunity to educate the IT public about AS400 / iSeries
Internet Accessible – Free Telnet products (www.symtrax.com)
Uploads and Downloads over internet with FTP Internet remote printing to IP addressable
printers SMTP Server – Send emails HTTP Server – web hosting Various CGI programming capabilities
![Page 5: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/5.jpg)
Career questions to keep you awake at night
What programming language should I be learning?
What computer platform will be in use in 5 to 10 years?
What can I learn today that will still be valuable in 5 to 10 years?
![Page 6: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/6.jpg)
Answer to these questions is:
The Internet
The Internet
The Internet
![Page 7: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/7.jpg)
TCP-IP issues are the same regardless of the platform
Once you configure FTP Server on AS/400, you already know how to do it on Windows
The FTP client on OS/400 is operationally very similar to the FTP on windows and Linux
Getting the SMTP server working involves learning about DNS, mail forwarding, third party relay
![Page 8: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/8.jpg)
Roadmap of next 25 slides
Write a “Welcome to my page” static HTML page Use PERL to output “Hello World” to browser Write an HTML form to accept PERMIT# Write a PERL program to process the CGI data, lookup
the permit inspections and write to browser Use a link to look up specific info about an inspection Read a non-keyed file and write it to the browser
![Page 9: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/9.jpg)
Non platform specific things to know for web site programming
HTML formatting– Static HTML– Forms with fields– Links with Query Strings
How to FTP HTML to web server Web server configuration Default folder, CGI-BIN directory
![Page 10: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/10.jpg)
Http Server Directives for Static HTML
So that a browser going to my AS/400 will be served the HTML in “index.html” in the “html” folder (get there with WRKLNK), use these two directives:
Pass /* /html/*Welcome index.html
There is nothing magic about the HTML folder. I created it from the WRKLNK screen
![Page 11: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/11.jpg)
To make a “Welcome” page
Use a PC to create a document named “index.html” with the following:
<html><body>Welcome to my home page</body></html>
Use FTP to put that document in the HTML folder Specifically, connect to 66.12.223.253 with remote
directory of /html Use a browser to go to 66.12.223.253 and you should
see the Welcome page
![Page 12: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/12.jpg)
Download and Install PERL
PERL (Practical Extraction and Report Language) An interpretted language (don’t compile) Written in C as a quick and dirty language Used by Unix administrators for years Probably the most common CGI programming
language www.cpan.org/ports/ to download the free library
![Page 13: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/13.jpg)
PERL Resources
Vast supplies of sample code on the internet Many Perl and CGI / PERL books “Writing CGI Applications with PERL” by Kevin
Meltzer and Brent Michalski
![Page 14: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/14.jpg)
PERL Executable Code
I used WRKLNK and MD PERL commands to create a directory named PERL
I FTP my PERL documents to the PERL directory
![Page 15: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/15.jpg)
Hello World Program
Use notepad to create a document named Hello.PL #!/usr/bin/perl
use CGI qw/:standard/;
print header;
print '<html><body>';
print 'Hello World';
print '</body></html>'; FTP document to AS/400
![Page 16: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/16.jpg)
Configure HTTP Server for CGI
Enable GET Enable HEAD Enable POST EXEC /cgi-bin/* /QSYS.LIB/T40CGI.LIB/*.PGM
%%EBCDIC%%
![Page 17: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/17.jpg)
CL Program
Compile a CL program named HELLO CALL PGM(PERLDIST/PERL) +
PARM('/PERL/HELLO.PL')
Program must be where you told the HTTP server that CGI-BIN programs are. In my case, the library T40CGI
Make sure QTMHHTTP and QTMHHTP1 have authority to everything
![Page 18: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/18.jpg)
Program execution time!
When browser goes to66.12.223.253/cgi-bin/hello
The HTTP server maps anything coming to “cgi-bin”
to T40CGI library
So, HTTP server tries to run the program HELLO
from T40CGI library
![Page 19: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/19.jpg)
![Page 20: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/20.jpg)
What is CGI?
Common Gateway Interface A defined standard for executing programs with
parameters Conceptually similar to a DDS display file Invoke a CGI program with either a link from a web
page or a submit button on a form Data arrives as a string of field names and values:
gtpermit.pgm?PERMT=1234&USR=David
![Page 21: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/21.jpg)
Different ways to process CGI
RPG ILE program using IBM supplied API’s (see Brad Stones’s eRPG book)
IBM’s Easy400 tool
(see www-922.ibm.com) 3rd Party Products like ProGen WebSmart PERL
![Page 22: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/22.jpg)
CGI form with submit button --- named GTPERMIT.HTML
<html><body>
<FORM METHOD="POST“ ACTION="http://66.12.223.253/cgi-bin/gtpermit">
Permit#
<INPUT TYPE="text" NAME="PERMT“ Maxlength=4><p>
<INPUT TYPE="Submit" VALUE="Submit“>
</form></body></html>
![Page 23: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/23.jpg)
![Page 24: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/24.jpg)
Program Execution Time!
When submit button is clicked:String “66.12.223.253/cgi-bin/gtpermit?PERMT=1234”Goes to IP address 66.12.223.253
The HTTP server maps anything coming to “cgi-bin” to T40CGI library
So, HTTP server tries to run the program GTPERMIT with the query string of ?PERMT=1234
We need a program named GTPERMIT to read this value and respond
![Page 25: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/25.jpg)
Use SQL to read AS/400 database
Need to read value from CGI form
and then… Build the SQL string:
SELECT * FROM T40CGI/INS WHERE INSPMT = ‘1234’
and then…
Show the data
![Page 26: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/26.jpg)
![Page 27: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/27.jpg)
![Page 28: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/28.jpg)
Put new Perl program on AS400
FTP this Perl program named “gtpermt” to the AS/400
Create a CL to run it Make sure the database and the CL program
are usable by QTMHTTP and QTMMHTP1 Click on the submit button
![Page 29: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/29.jpg)
![Page 30: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/30.jpg)
Add a link to see details of inspection
Add this line as the last column of table: print q(<td><a href=showdetl?PERMT=
$data->{INSPMT}&TYP=$data->{INSTYP} >Details</a></td>\n);
Builds a string like:
<a href=showdetl?PERMT=1234&TYP=DW>
Details</a>
![Page 31: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/31.jpg)
![Page 32: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/32.jpg)
Perl Program named showdetl.pl
Get parms from query string Build the SQL string:
SELECT * FROM T40CGI/INS WHERE INSPMT = ‘1234’ AND INSTYP = ‘DW’
and then…
Show the data
![Page 33: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/33.jpg)
![Page 34: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/34.jpg)
![Page 35: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/35.jpg)
Put new program on AS/400
FTP this Perl program named “showdetl” to the AS/400
Create a CL to run it Make sure the CL program is usable by
QTMHTTP and QTMMHTP1
![Page 36: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/36.jpg)
![Page 37: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/37.jpg)
![Page 38: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/38.jpg)
At Your Next Company Meeting
Can users use the internet to get on the iSeries?
Can people upload and download data from the AS400 over the internet?
Can our computer host web pages? Can we process CGI input? Can we run PERL?
![Page 39: Using Perl on an AS/400 / iSeries](https://reader035.vdocuments.site/reader035/viewer/2022081503/568146b7550346895db3df81/html5/thumbnails/39.jpg)
Duh!!!!
It’s an AS/400!