Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can we keep our cgi code on the new AIX 7.2 machine and install the new CGI-4.57 ? How can i refer this new CGI on my scripts?
Here is the script
Thanks in advance#!/usr/bin/perl use CGI; use lib qw(../cgi-lib); use POSIX qw(strftime); use siteconfig; use parseFile; use libUtil; use strict; my $PROC_MAIN_PAGE = $siteconfig::PROC_MAIN_PAGE; #"../cgi-dat +a/procStatus.html" my $ERROR_PAGE = $siteconfig::ERROR_PAGE; # "../cgi-da +ta/error.html"; my $ERROR_LOG = $siteconfig::PROC_ERROR_LOG; #"procerr.lo +g"; my $PROC_STATUS_SCRIPT = $siteconfig::PROC_STATUS_SCRIPT; #"/hci/root3 +.7.1P/bin/hciprocstatus"; my $CONN_STATUS_CGI = $siteconfig::CONN_STATUS_CGI; #connStatus. +cgi my $IMG_DIR = $siteconfig::IMG_DIR; #/demo/img my $CSS_DIR = $siteconfig::CSS_DIR; #/demo/scrip +t my $HCI_PROFILE = $siteconfig::HCI_PROFILE; #/home/hci/. +cluster/hci.profile my $ARROW_UP = "<img src=\"$IMG_DIR/arrow_up.gif\" alt=\"\"> +"; my $ARROW_DOWN = "<img src=\"$IMG_DIR/arrow_down.gif\" alt=\"\ +">"; sub getProcStatus{ my $site = $_[0]; my $input = `$PROC_STATUS_SCRIPT 2>&1`; #Split by line my @list = split(/\n/, $input); my ($i, %proc, %stat, %msg, $output); #Ignore the first 2 lines...(verify title, else error returned) if ( ($list[0] =~ /Process/) && ($list[0] =~ /State/) && ($list[0] = +~ /Message/)){ for ($i=2; $i<=$#list; $i++){ my @line = (substr($list[$i],0,15), substr($list[$i],16,9), su +bstr($list[$i],25,-1)); #Remove space char and \n from data, and save it into associat +ive arrays... $line[0] =~ s/ //gs; $line[1] =~ s/ //gs; $line[2] =~ s/\n//gs; $proc{$line[0]} = $line[0]; $stat{$line[0]} = $line[1]; $msg{$line[0]} = $line[2]; } my ($key, $count) = ("",0); foreach $key (sort keys %proc){ my ($color, $upkey, $img) = ("",$key,""); $upkey =~ tr/a-z/A-Z/; if ($stat{$key} =~ /running/i){ $color = "#80CC65"; #80FF80; $img = $ARROW_UP; }else{ $color = "#F98580"; #FF8080; $img= $ARROW_DOWN; } #if ($count % 2) { $color = "#F0F0F0"; }else{ $color = "#FFFFFF +"; } #$count++; #$output .="\n<TR bgcolor=\"$color\"><td align=left><FONT face= +\"arial,helvetica\" SIZE=\"2\"><B>". # "\n<a href=\"#\" onClick=openPopup(\"$CONN_STATUS_CG +I?site=$site&proc=$key\",\"$upkey\")>$upkey</a></B></FONT></td>". $output .="\n<TR bgcolor=\"$color\"><td align=left><FONT face=\ +"arial,helvetica\" SIZE=\"2\"><B>". "\n<input type=button onClick=openPopup(\"$CONN_STATU +S_CGI?site=$site&proc=$key\",\"$upkey\") value=$key></B></FONT></td>" +. "\n<td align=left>". "\n<b><FONT face=\"arial,helvetica\" SIZE=\"2\">". "$stat{$key}</FONT></b></td>". "\n<td align=left>". "\n<b><FONT face=\"arial,helvetica\" SIZE=\"2\">$msg{ +$key}</FONT></b></td>". "\n</TR>\n"; } }else{ #Error when getting process -- append error to log file $output = "<TR><TD colspan=3 align=center><font face=\"arial,hel +vetica\" size=2 color=red><b><pre>$input</pre></b>" . "</font><br></TD></TR>"; libUtil::logError($ERROR_LOG,$input); } return $output; } sub main{ # print CGI::header(-expires=>'yesterday',-pragma=>'no-cache'); # print CGI::header; # print "Cache-Control: no-cache"; my $query = new CGI(); my ($site, $output, $res, @site_list, %info); print $query->header(-expires=>'now'); $info{"BANNER_COLOR"} = libUtil::bannerByHost(); $info{"CURDATE"} = strftime "%B %d %Y, %H:%M:%S", localtime(); $info{"IMG_DIR"} = $IMG_DIR; $info{"CSS_DIR"} = $CSS_DIR; ($res, @site_list) = libUtil::getSiteList(); #Set env var according to site... if (defined($query->param('site'))){ $site = $query->param('site'); }else{ $site = $site_list[0]; } #No site found... if ($res == 0){ $info{"SITE"} = "-No site-"; $info{"SITE"} =~ tr/a-z/A-Z/; $info{"SITE_LC"} = "-No site-"; #Site in lower case $info{"SITE_SELECTION"} = "<option value=\"\" selected>-No Site F +ound-</option>"; $info{"PROC_STATUS"} = "<TR><TD colspan=3 align=\"center\"><font +face=\"arial,helvetica\" size=2 color=red><b>". "NO SITE FOUND. Verify that site list is d +efined in $HCI_PROFILE.</b>" . "</font><br></TD></TR>"; }else{ libUtil::setEnvVar($site); $info{"SITE"} = $site; $info{"SITE"} =~ tr/a-z/A-Z/; $info{"SITE_LC"} = $site; #Site in lower case while ($res = shift(@site_list)){ my $res_up = $res; $res_up =~ tr/a-z/A-Z/; if ($res eq $site){ $info{"SITE_SELECTION"} .= "<option value=\"$res\" selected> +$res_up</option>\n"; }else{ $info{"SITE_SELECTION"} .= "<option value=\"$res\">$res_up</ +option>\n"; } } $info{"PROC_STATUS"} = &getProcStatus($site); } $output = parseFile::parseTemplate($PROC_MAIN_PAGE,\%info); print $output; } &main();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: CGI.pm on AIX 7.2
by eyepopslikeamosquito (Archbishop) on Jul 21, 2023 at 00:23 UTC | |
Re: CGI.pm on AIX 7.2
by Corion (Patriarch) on Jul 21, 2023 at 06:33 UTC | |
Re: CGI.pm on AIX 7.2
by ikegami (Patriarch) on Jul 22, 2023 at 18:36 UTC | |
by Anonymous Monk on Aug 01, 2023 at 16:54 UTC | |
by haj (Vicar) on Aug 01, 2023 at 19:36 UTC | |
by ikegami (Patriarch) on Aug 04, 2023 at 00:58 UTC |