PROFESSORSPARKIE
Instructor
Can anyone help me with the following cgi(perl) program execution?
Here is what I am doing.
1. Apache xampp is installed on a Windows XP system.
2. Xampp Control Panel says that Apache is running.
3. I see the Apache icon on the Start Bar.
4. I placed the following HTML file in “C:\apache\htdocs” folder as “SIMPLE.HTML”.
<html>
<body>
<h3>
<center>
<TABLE WIDTH=80% BORDER=13 BORDERCOLOR=BLUE>
<TD>
<FORM METHOD="POST" ACTION="simple.pl">
<CENTER>
<TABLE BORDER=1>
<TR> <TD>- REVIEW THE COMPLETE INVENTORY FILE STATUS. -</TD></TD>
</TABLE>
<BR>
<INPUT TYPE="SUBMIT" VALUE="CLICK TO DISPLAY ALL OF THE RECORDS">
</CENTER>
</FORM>
</td>
</table>
</center>
</body>
</html>
5. I placed the following cgi(perl) file in “C:\apache\htdocs” folder as “SIMPLE>PL”.
#!"\xampp\perl\bin\perl.exe"
print "Content-Type: text/html\n\n";#!/usr/bin/perl
#**********************************************************************
#* THIS PROGRAM READS THE STANDARD INPUT AND THEN *
#* LISTS OUT A TEXT FILE & PRINTS TO THE STANDARD OUTPUT *
#**********************************************************************
print "<HTML><HEAD><TITLE>Here comes a listing!\n</TITLE></HEAD>";
print "<BODY>";
print "<BR>";
if (open(INV_IN, "<c:\\xampp\\htdocs\\INV_RPT.TXT"))
{
# run this listing if open succeeds
}
else
{
print "Cannot open Mydatafile!\n";
exit 1;
}
while(defined($a=<INV_IN>))
{
print $a;
print "<BR>\n";
}
close(Myfile);
print "file Myfile listed.\n";
print "<BR>\n";
print "</BODY></HTML>\n";
exit 0;
THEN:
6. I have placed the files in the same folders.
When I use the latest Mozilla browser to load the “html” web page and execute it the web page loads OK and when I select the <FORM> tag to load & run the perl program I just get a listing of the perl program.
After it failed I did the following and tried to use the “cgi” option.
I placed the same file in “C:\apache\htdocs” folder as “simple.cgi” & updated the <form> tag.
I also placed the perl program as “smple.pl” & “simple.cgi” in the “C:\apache\cgi.bin” folder and restested.
The browser finds the files, the perl interpreter is in it proper location “c:\perl\bin\perl” and in “c:\xampp\perl\bin\perl” but is not executed. I have tried being more & less speciic on the shbang command.
I have tried every combination with no success.
I write, using a cloud hosted web site with similar programs with no problems. The problem is that, the Apache server and/or the browser are not working together to catch the web page ACTION="simple.pl" request and passing it to perl.
Computer thought: I teach a lot of programming so I can learn. You can never learn it all.
Here is what I am doing.
1. Apache xampp is installed on a Windows XP system.
2. Xampp Control Panel says that Apache is running.
3. I see the Apache icon on the Start Bar.
4. I placed the following HTML file in “C:\apache\htdocs” folder as “SIMPLE.HTML”.
<html>
<body>
<h3>
<center>
<TABLE WIDTH=80% BORDER=13 BORDERCOLOR=BLUE>
<TD>
<FORM METHOD="POST" ACTION="simple.pl">
<CENTER>
<TABLE BORDER=1>
<TR> <TD>- REVIEW THE COMPLETE INVENTORY FILE STATUS. -</TD></TD>
</TABLE>
<BR>
<INPUT TYPE="SUBMIT" VALUE="CLICK TO DISPLAY ALL OF THE RECORDS">
</CENTER>
</FORM>
</td>
</table>
</center>
</body>
</html>
5. I placed the following cgi(perl) file in “C:\apache\htdocs” folder as “SIMPLE>PL”.
#!"\xampp\perl\bin\perl.exe"
print "Content-Type: text/html\n\n";#!/usr/bin/perl
#**********************************************************************
#* THIS PROGRAM READS THE STANDARD INPUT AND THEN *
#* LISTS OUT A TEXT FILE & PRINTS TO THE STANDARD OUTPUT *
#**********************************************************************
print "<HTML><HEAD><TITLE>Here comes a listing!\n</TITLE></HEAD>";
print "<BODY>";
print "<BR>";
if (open(INV_IN, "<c:\\xampp\\htdocs\\INV_RPT.TXT"))
{
# run this listing if open succeeds
}
else
{
print "Cannot open Mydatafile!\n";
exit 1;
}
while(defined($a=<INV_IN>))
{
print $a;
print "<BR>\n";
}
close(Myfile);
print "file Myfile listed.\n";
print "<BR>\n";
print "</BODY></HTML>\n";
exit 0;
THEN:
6. I have placed the files in the same folders.
When I use the latest Mozilla browser to load the “html” web page and execute it the web page loads OK and when I select the <FORM> tag to load & run the perl program I just get a listing of the perl program.
After it failed I did the following and tried to use the “cgi” option.
I placed the same file in “C:\apache\htdocs” folder as “simple.cgi” & updated the <form> tag.
I also placed the perl program as “smple.pl” & “simple.cgi” in the “C:\apache\cgi.bin” folder and restested.
The browser finds the files, the perl interpreter is in it proper location “c:\perl\bin\perl” and in “c:\xampp\perl\bin\perl” but is not executed. I have tried being more & less speciic on the shbang command.
I have tried every combination with no success.
I write, using a cloud hosted web site with similar programs with no problems. The problem is that, the Apache server and/or the browser are not working together to catch the web page ACTION="simple.pl" request and passing it to perl.
Computer thought: I teach a lot of programming so I can learn. You can never learn it all.