Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
We have a cgi web application running with Perl (5.20.1) and CGI.pm that is embedded under Aix 6.1. We configure a new Machine with AIX 7.2 no longer CGI.pm exist.

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

#!/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();
Thanks in advance

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

    eyepopslikeamosquitos advice of using your own Perl is sound. In the short term, whether you use the system Perl or your own Perl, you can (well, must) install CGI from CPAN.

Re: CGI.pm on AIX 7.2
by ikegami (Patriarch) on Jul 22, 2023 at 18:36 UTC

    Are you asking if your code will work with the newest version of CGI? Probably. You could always install the version you used on the older box, but I'd try the latest version first.

      Hi,

      I'm having the following error on apache log when i tried to run the command use CGI on my .cgi script:

      ####Script .cgi ##### #!/usr/bin/perl use CGI; use lib qw(../cgi-lib); use POSIX qw(strftime); use siteconfig; use parseFile; use libUtil; use strict; ########
      ###Log Apache [Tue Aug 1 12:39:01 2023] [notice] Apache/1.3.9 (Unix) configured -- +resuming normal operations Can't locate object method "new" via package "CGI" (perhaps you forgot + to load "CGI"?) at /usr/opt/perl5/lib/site_perl/5.28.1/CGI.pm line 7 +. Compilation failed in require at /ieweb/webmon61/cgi-bin/procStatus.cg +i line 3. BEGIN failed--compilation aborted at /ieweb/webmon61/cgi-bin/procStatu +s.cgi line 3
      Thank you

        This looks like a broken, or at least inconsistent installation.

        Examine the file /usr/opt/perl5/lib/site_perl/5.28.1/CGI.pm: Your code seems to assume that this is the library CGI, but this library definitely does not call CGI->new.

        Perhaps you can track down where this CGI.pm comes from, and how /usr/opt/perl5/lib/site_perl/5.28.1/ ended up in your @INC directory. Or you could try installing CGI.pm with the package manager of your distribution, or from CPAN, and make sure that this version is used instead of your weird one.

        Also, cgi-lib seems to be something from a very distant past.... where did that script come from? Perl 4?

        Something's really wrong with /usr/opt/perl5/lib/site_perl/5.28.1/CGI.pm.