http://www.perlmonks.org?node_id=862733

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

Question: In undermentioned I am calling bugzilla_QAmembers.cgi script but that does not takes data and displays nothing. Also is "qaname=$Name" I am correctly assigning, please advice.

foreach my $num (keys %bug_d) { $bug_detail{$num} = "<A HREF=\"http://t34.qa.qualys.com/Vulns +igs_Release/cgi-bin/bugzilla_QAmembers.cgi?bug_id=$num&qaname=$Name\" + TARGET=\"_blank\">$bug_d{$num}</A>"; }

MAIN SCRIPT

$q = new CGI; print $q->start_html(); print $q->startform; print $q->strong("Compliance Engineer Details"); print $q->br; print $q->br; print $q->popup_menu( -name=>'Compliance Members', -values=>['Alan Covell','Andy Hu','Chris Russo','Darren Wei','Dianf +ang Gao','David Mcmillan','Jin Wu','Jingyang (Johnson) Liu','Kenneth +trant','Sridhar Gundubogula','Steve Nixon','Stephen willis','Vaibhav +Mehrotra','Wolfgang Kandek'], -default=>'Vaibhav Mehrotra', ); print $q->submit('action','submit'); $Name = $q->param(-name=>'Compliance Members'); print $q->endform; print $q->end_html; my $tankdbh = QualysVulnQA::bugsopen(); sub general_query { my $dbh = shift @_; my $query = shift @_; my $sth = $dbh->prepare($query) || die "Prepare error: $! for sql: $q +uery\n"; $sth->execute() || die "Execute error: $!\n"; my $results = $sth->fetchrow_array(); return $results; } my $Compliance_Member = "select count(*) as count1,bug_status from bug +s,profiles where (bugs.qa_contact=profiles.userid) and product_id = 1 +9 and component_id = 271 and profiles.realname='$Name' group by bug_s +tatus"; my $sth = $tankdbh->prepare($Compliance_Member) || die "Prepare error: + $!\n"; $sth->execute() || die "Execute error: $!\n"; my %bug_d; while (my $rec = $sth->fetchrow_hashref) { $count = $rec->{count1}; $bug_status = $rec->{bug_status}; $bug_d{$bug_status} = $count; } foreach my $num (keys %bug_d) { $bug_detail{$num} = "<A HREF=\"http://t34.qa.qualys.com/Vulns +igs_Release/cgi-bin/bugzilla_QAmembers.cgi?bug_id=$num&qaname=$Name\" + TARGET=\"_blank\">$bug_d{$num}</A>"; }

bugzilla_QAmembers.cgi -- script

#!/usr/bin/perl use strict; #use warnings; use QualysVulnQA; print "<html>"; print '<head>'; print "Content-Type: text/html\n\n"; print '<title>Compliance Bugzilla</title>'; print '<img src="/images/heading_1.gif" alt="[Qualys Intranet]" width= +"678" height="112"></head>'; print '<body BGCOLOR="#638cc8" LINK="Blue" TEXT="black" VLINK="Yellow" + ALINK="Yellow">'; print "</body>"; print "</html>"; my $tankdbh = QualysVulnQA::bugsopen(); my $request_method = $ENV{'REQUEST_METHOD'}; my $query_string = $ENV{'QUERY_STRING'}; my $path_info = $ENV{'PATH_INFO'}; my $content_length = $ENV{'CONTENT_LENGTH'}; # Parse web content my %webin; my @pairs = split(/&/, $query_string); print @pairs; foreach my $pair (@pairs) { (my $name, my $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/^M//g; $value =~ s/~!/ ~!/g; $webin{$name} = $value; } my $Name= $webin{"qaname"}; my $bug = $webin{"bug_id"}; my $new = "select bug_id as Bug_Number,short_desc as Bug_Summary from +bugs,profiles where (bugs.qa_contact=profiles.userid) and product_id += 19 and component_id = 271 and bug_status='$bug' and profiles.realna +me='$Name'"; my $results = QualysVulnQA::generic_db_query($tankdbh,$new); #print $result; #my $status; #SWITCH: { # $status = "NEW", last SWITCH if ($bug == 'NEW'); # $status = "ASSIGNED", last SWITCH if ($bug == ' +ASSIGNED'); # $status = "RESOLVED", last SWITCH if ($bug == +'RESOLVED'); # $status = "VERIFIED", last SWITCH if ($bug == +'VERIFIED'); # $status = "CLOSED", last SWITCH if ($bug == 'C +LOSED'); # } # Output to browser print STDOUT "<HTML><BODY>\n"; #print STDOUT "<CENTER><H3>Compliance Bugzilla Bugs in '$status' State +</H3></CENTER>\n"; print STDOUT "<TABLE BORDER=1>\n"; print STDOUT "<TR><TH>Bug_Number</TH><TH>Bug_Summary</TH></TR>\n"; foreach my $ref (@{$results}) { my $Bug_Number = $ref->{"Bug_Number"}; my $Bug_Summary = $ref->{"Bug_Summary"}; my $bug = "<A HREF=\"https://bugs.intranet.qualys.com/show_bug.cg +i?id="; # TARGET=\"_blank\"; $bug .= $Bug_Number; $bug .= "\">$Bug_Number</A>"; print STDOUT "<TR><TD>$bug</TD><TD>$Bug_Summary</TD></TR>\n"; } print "</TABLE>\n"; print STDOUT "</BODY></HTML>\n";