CGI Script issue.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

CGI Script issue.

Postby bogasrikanth » 22. October 2008 18:17

Hi friends,

i have a problem with the following script. Could you please correct this. It is indeed very urgent please look in to this.

I am calling this script on server X and this would inturn call server Y. this script should get the script from the server Y and display to the users of server Y. But, I am finding lot many errors in the script. I donno any thing about the CGI Scripting. Could you please fix this.

Thanks


#!"C:\Server\xampp\perl\bin\perl.exe"

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use CWT::MySQL;

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;


my $cwt = new CWT::MySQL();
my $url = $cwt->url;
my $cgi = new CGI;

$cwt->set( page_title => "CAVE Software");
my $action = $cwt->param('action');



# Function map for setting permissions and for specifying the action buttons
my %FunctionMap = (
SHOW_INDEX => { ROLES => [] },
SHOW_LOAD => { ROLES => [] },
SHOW_ML => { ROLES => [] },
SUBMIT_FORM => { ROLES => [] },
AUTO => { ROLES => [] },
SHOW_ETOOLS => { ROLES => [] },
);
#
# Map verbose parameter names into short versions and set the command
# to 'AUTO' if it isn't defined in the FunctionMap.
#
my $cmd = $cwt->param('CMD') || 'AUTO';
foreach (keys %FunctionMap) {
$cmd = $_ if ($cmd eq $FunctionMap{$_}{BUTTON});
}
$cmd = 'AUTO' unless defined $FunctionMap{$cmd};
$cwt->set( MAN_SECTION => $cmd );

#
# Send'em packin' if they don't have permission to see this function.
#
$cwt->require_role($FunctionMap{$cmd}{ROLES});

print $cwt->header();
print $cwt->start_html();
print $cgi->header();
print $cgi->start_html(-title=>"CAVE Software");


#
# SHOW_INDEX -- to see index.php
#
if ($cmd eq 'SHOW_INDEX') {

show_index();


#
#SHOW_ML
#
} elsif ($cmd eq 'SHOW_ML'){

show_ml();

#
#SHOW_LOAD
#
} elsif ($cmd eq 'SHOW_LOAD'){

show_load();
#
# SUBMIT_FORM
#
} elsif ($action) {

submit_form();

#
# AUTO -- Automatic function (if no CMD is given)
#
} elsif ($cmd eq 'AUTO') {

main_links();

#
# DEFAULT - Should never get here (AUTO should be the default if the entered
# parameter is not recognized).
#
} elsif ($cmd eq 'SHOW_ETOOLS') {
show_etools();

}
else {

print qq{<P>Invalid command ($cmd)};
}

#print $cwt->end_html();
print $cgi->end_html();
exit 0;


sub show_etools
{
print qq{<h1> I AM HERE ;-)</h1>};
$q = new CGI;
print $q->redirect("http://aristotle.eng.auburn.edu/version9/index.php");
}

####################################
# show_index
####################################
sub show_index
{

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('http://aristotle.eng.auburn.edu/Version2/statistical/index.php');


if ($response->is_success) {
print $response->content;
}else{
die $response->status_line;
}
}

####################################
# show_ml
####################################
sub show_ml
{

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('http://aristotle.eng.auburn.edu/Version3/MatDB/fload.php');


if ($response->is_success) {
print $response->content;
}else{
die $response->status_line;
}
}



####################################
# show_load
####################################
sub show_load
{

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('http://aristotle.eng.auburn.edu/Version3/EnvDB/load.php');


if ($response->is_success) {
print $response->content;
}else{
die $response->status_line;
}
}

####################################
# submit_form
####################################
sub submit_form
{

my %form;
my $pars;
my $temp;
foreach my $p (param()) {
$form{$p} = param($p);
$temp = $form{$p};
$pars .= qq{$p=>"$temp",};
}

my $faction = qq{http://aristotle.eng.auburn.edu};
$faction .= $action;

my $ua=LWP::UserAgent->new();
my $req= POST "$faction",Content=>\%form;
my $content=$ua->request($req);


if ($content->is_success){
print $content->content;
}else{
print $content->status_line . "\n";
}


}

####################################
# main_links
####################################
sub main_links
{
print qq{<p><table align="center" width="100%"><tr><td>\n};
print qq{<table border="0" cellpadding="4" cellspacing="4" width="90%">\n};
print qq{<center><font size=+3>CAVE Software</font></center>};
print qq{<tr><td><br><ul>\n};
print qq{<li>\n};
print qq{<a href="http://aristotle2.eng.auburn.edu/version10/index.php">Click to use eTools</a></li>\n};
print qq{</li></ul></td></tr></table>\n};
print qq{</td></tr></table>\n};
}



------WebKitFormBoundary1cYMdngFzste8gxM
Content-Disposition: form-data; name="Item.Attachment.unused"

0
bogasrikanth
 
Posts: 18
Joined: 13. August 2008 19:02

Postby Sharley » 23. October 2008 03:35

When you paste a script like this please enclose it in the code brackets and check mark the Disable Smilies in this post box as you have included a smiley in the code.

Can you paste here your actual error messages please?

Look in .\xampp\apache\logs\error.log file for any clues and paste them here but only those errors about your cgi issues.

How are you running the cgi scripts - what URI do you use?

Where have you put the .cgi file?

When I run your script that I named here.cgi I get this initial error:
Code: Select all
[error] [client 127.0.0.1] Premature end of script headers: here.cgi
[error] [client 127.0.0.1] Can't locate CWT/MySQL.pm in @INC (@INC contains: C:/xampp/perl/site/lib C:/xampp/perl/lib .) at C:/xampp/cgi-bin/here.cgi line 6.\r
[error] [client 127.0.0.1] BEGIN failed--compilation aborted at C:/xampp/cgi-bin/here.cgi line 6.\r

Line 6 = use CWT::MySQL;
This Perl module CWT:MySQL is an error as this module does not exist anywhere on the Internet that I could find - it may be a proprietary module created by the script's author and would have to be installed to use the script.

This line 6 would have to be corrected for the script to proceed beyond this line.

Check with where you acquired the script and get confirmation of the contents of line 6 and the other lines that reference CWT.

After commenting out line 6 there where many more issues with this script including syntax errors and global symbol requires issues.

Too many errors for me to bother with so I suggest a visit to the script's author for some serious troubleshooting of this script.

FWIW - For a list of installed modules installed in the Perl instance within XAMPP go here (it may take a while to load the page) :
http://localhost/perl/perlinfo.pl

BTW did you install the XAMPP Perl Addon?
Not that installing the Addon would help to sort the many issues with this poor old cgi script.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests