Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

linking to perl in xampp apache cgi

linking to perl in xampp apache cgi

linking to perl in xampp apache cgi

Can anyone help me with the following cgi(perl) program execution? I submitted it in the perl threads with no response. I am retrying here for help.

It seems there is a lot less participation on some threads lately.

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".
   <FORM METHOD="POST" ACTION="simple.pl">

5.  I placed the following cgi(perl) file in "C:\apache\htdocs" folder as "SIMPLE>PL".


print "Content-Type: text/html\n\n";#!/usr/bin/perl
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
     print "Cannot open Mydatafile!\n";
     exit 1;
     print $a;
     print "<BR>\n";
print "file Myfile listed.\n";
print "<BR>\n";
print "</BODY></HTML>\n";
exit 0;

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.  

RE: linking to perl in xampp apache cgi


Have you ensured that the Apache httpd.conf Configuration file is set to enable CGI programmes, and that everything else in the config looks good to go?


RE: linking to perl in xampp apache cgi

I am new to Apache but these commands are in the file.

AddHandler cgi-script .pl
AddHandler cgi-script .cgi

I tried different combination s but just got a perl listing.


Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

RE: linking to perl in xampp apache cgi

What happens if you just type the URL of the CGI script in the address bar of your browser? Does the script execute, or do you just get a listing?

My guess is that you'll get a listing, and that it's an issue with how the server is configured. Try asking in forum65: Apache: HTTP Server instead.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

RE: linking to perl in xampp apache cgi

It does not run, it just lists out.

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

RE: linking to perl in xampp apache cgi

[0] There are things misunderstood in the set up. This gets the basic laid out, though it may not get understood immediately:

[1] You have to have a dedicated directory where the server would "execute" the file without explicitly specifying the host such as perl.exe. It can be under the documentroot, but, most probably it may not be.

[1.1] Suppose you have you documentroot point to:
And it seems that you want the dedicated directory for cgi be:
(The document suggests a name cgi-bin for the vitual directory. Let's use it for instance) Then in the httpd.conf, you add the ScriptAlias line like this:
    ScriptAlias /cgi-bin/ "c:/apache/cgi.bin"

[1.1.1] Even the cgi.bin directory is not under htdocs, virtual-directory-wise, it is still read as a path of this form:

[1.1.2] In your html form, you submit the form to the cgi like this.
    <form method="POST" action="/cgi-bin/simple.pl">
and put the simple.pl into the c:\apache\cgi.bin directory. Once you that, you will either get the desired output or you will be met with Server Internal Error or alike if the .pl is actually containing error during the execution. (You won't get a "request to download the simple.pl" or "Forbidden, permission denied etc...")

[2] If what said in [1] successfully done, you can just as well experimenting using another dedicated directory directly under documentroot, like it seems you wanted to call cgi.bin. In that case, you add another block in the httpd.conf using Directory, like this.

<Directory "c:/apache/htdocs/cgi.bin">
    Options +ExecCGI

[2.1] And again you can then submit a form to the .pl or .cgi located inside that dedicated directory, like this.
    <form method="POST" action="/cgi.bin/simple.pl">
(watch the difference this time cgi.bin there).

[2.2] Within htdocs/cgi.bin, you should not put plain html or other kind of text file for instance in the hope of navigating to the directory to get to them. It would then be forbidden and permission is denied.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close