Perl 1997 Perl As A System Glue

Click here to load reader

download Perl 1997 Perl As A System Glue

of 23

  • date post

    06-Dec-2014
  • Category

    Technology

  • view

    1.213
  • download

    4

Embed Size (px)

description

This presentation, at the 1st Perl Conference, introduced cross platform perl/unix web development. Of special interest was the examination of what are now called database sockets. This may have been the first presentation of the subject.

Transcript of Perl 1997 Perl As A System Glue

  • 1. Perl As A System Glue Patrick M. Benson University of Washington Information Systems http://weber.u.washington.edu/~pbenson email: pbenson@cac.washington.edu

2. Overview of Examples

  • File Store-and-Forward
  • Introductory Level Example
  • Perl CGI
  • Intermediate Level Example
  • Half-a-Perl Concept
  • SQL Development

3. File Store-and-Forward

  • VAX/VMS with Multinet outside our firewall running FOCUS under DCL
  • RS-6000 UNIX/AIX inside our firewall with strict security measures
  • IBM-309x/VM with an unknown Comm System on dedicated RJE line through our firewall

4. File Store-and-Forward 5. File Store-and-Forward

  • RSH and FTP work because ...
  • I trust you enough to let you talk to me, Ill take data files you say are safe.
  • You trust me enough to give me your account / password and to let me send a copy of your data file back to you.

6.

  • Perl in this process(See Listing 2, RS6000/AIX Perl Script)
  • IF Statements, Logical Operators, Code Blocks
  • 16. if ($#ARGV != 1) {
  • 17.print *******************************************;
  • 18.print* ARGUMENT MISMATCH ERROR #, $#ARGV *;
  • 19.print******************************************* ;
  • 20.exit -1;}
  • Arguments, Array Notation, Concatenation, Constants
  • 23. $infile= $ARGV[0];
  • 24. $chkfile = $infile . _check;
  • Back-Tic Execution, Nested Quotes, Imbedded Pipes
  • 43. $get_file= echo get $outfile $chkfile | ftp vsvm.dis.wa.gov;

File Store-and-Forward 7. Overview of Examples

  • File Store-and-Forward
  • Introductory Level Example
  • Perl CGI
  • Intermediate Level Example
  • Half-a-Perl Concept
  • SQL Development

8. Perl CGI

  • Web Client (PC, Mac, Xterm with Netscape 2.1 or better or similar, marginal HTML 3.0 or better compliant)
  • Web Server (Perl 4.2 or better)
  • Data Server (Unix Box with Informix, Sybase, Oracle ISQL or similar)

9. Perl CGI 10. Perl CGI

  • Content, Cache Control, Libraries, Initialization
  • Accept static HTML parameters & Main Driver
  • Construct ISQL command to meet request
  • Copy the ISQL command through the firewall to a data file
  • Pass filename and CAT statements as a parameter to ISQL command file
  • Parse returned string into rows
  • Build HTML Page

11. Perl CGI

  • See Listing 3, Perl CGI
  • Content, Cache Control, Libraries, Initialization
  • 9.print "CONTENT-TYPE: text/html"," ";
  • 10. print "Pragma: no-cache","";
  • 12. require "/www/world/cgi-bin/cgi-lib.pl";
  • 14. $rcp_user= oasis;
  • 15. $rcp_cmd= /usr/ucb/rcp;
  • 16. $rcp_host= equip.u.washington.edu;
  • 18. $rsh_user= oasis;
  • 19. $rsh_cmd= /usr/ucb/rsh;
  • 21. $sql_host= equip.u.washington.edu;
  • 22. $sql_db= oasisdev@equipdev;
  • 27. $rcp_destination = $rcp_user . @ . $rcp_host . :.;
  • 28. $sql_user = $sql_host . -l . $rsh_user . ;

12. Perl CGI

  • See Listing 3, Perl CGI
  • Accept static HTML parameters & Main Driver
  • 37. &ReadParse;
  • 39. $table_name = $in{'table_name'};
  • 41. $set_extract;
  • 42. &run_extract;
  • 43. &write_report;
  • 45. exit;

13. Perl CGI

  • See Listing 3, Perl CGI
  • Construct ISQL command to meet request
      • 49. sub set_extract {
      • 53.$sellist= name_value, name_full_text;
      • 54.$passlist= '$table_name';
      • 55.$sql_tables = UNLOAD TO TEMPTBL SELECT . $sellist
      • 56.. FROM names
      • 57.. WHERE name_type = . $passlist
      • 58.. ;
      • 59. }

14. Perl CGI

  • See Listing 3, Perl CGI
  • Copy the ISQL command through the firewall to a data file
      • 76. $info_time= `$rsh_cmd $sql_user "/bin/date "`;
      • 77. if ($info_time eq '') {
      • 78.print "

        Database Server not responding ... try again later.";

      • 79.exit;
      • 80. }
      • 85. $d = `rcp isql_tables.sql $rcp_destination`;

15. Perl CGI

  • See Listing 3, Perl CGI
  • Pass filename and CAT statements as a parameter to ISQL command file
  • 94. $info = `rsh $sql_user "$rsh_file $sql_db isql_tables.sql; cat -e -vTEMPTBL ; rm TEMPTBL"`;

16. Perl CGI

  • See Listing 3, Perl CGI
  • Parse Returned String into Rows
  • 100. @table_data = split('|$',$info);
  • 101. $row_count = $#table_data;
  • 102. @row_data = split('|',$table_data[0]);
  • 103. $col_count = $#row_data + 1;

17. Perl CGI

  • See Listing 3, Perl CGI
  • Build HTML Page
  • 108. sub write_report {
  • 110&build_headers;
  • 111.&write_header;
  • 112.&write_body
  • 113&write_footers;
  • 114. }

18. Perl CGI

  • See Listing 3, Perl CGI
  • Build HTML Page - Build Headers
  • 122. $table_title[0] = Column 1;
  • 123. $table_title[1] = Column 2;
  • 125. if ($table_name eq class) {
  • 126.$table_title[0] = Class Code;
  • 127.$table_title[1] = Class of Equipment;
  • 128. elsif ($table_name eq "cond") {
  • 129.$table_title[0] = Condition Code;
  • 130.$table_title[1] = Asset's Present Condition;}
  • (and so on until all possible table column titles are set)
  • 140. }

19. Perl CGI

  • See Listing 3, Perl CGI
  • Build HTML Page - Write Header
  • 144. sub write_header {
  • 148. print
  • 202.

";

  • 203.} else {
  • 204.print " $row_data[$j] ";
  • 205.}
  • 206.}

22. Perl CGI 23. Perl As A System Glue

  • Pluses
  • Cost effective cross platform superglue.
  • Efficient and Structured code possible
  • 1 hour of Perl = 8 hours of COBOL
  • Minuses
  • 10 ways to mess up maintenance staff
  • Difficult post-implementation support environment
  • All the HTML Bandwagon problems