Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am very new to CGI programming in Perl.

In order to learn it i installed xampp 2 days back. But I am unable to execute my perl code . The code goes as folows:

#!/usr/bin/perl
use CGI;
$co = new CGI;
print $co->header,
$co->start_html(title=>'CGI Example'),
$co->center($co->hi('Subhayan welcome to CGI')),
$co->end_html;

Have saved the code in a text file named : Subhayan1.cgi and kept it in the folder cgi-bin under xampp folder in C drive.

When i try to execute this through my web browser typing : "http://localhost/cgi-bin/Subhayan1.cgi" it comes up with a "Object not found page".

I checked the apache configuration file under : xampp/apache/conf/httpd.conf.

I checked the entry : ScriptAlias /cgi-bin/ "C:/xampp/cgi-bin/"

It looks like pointing to the correct directory.

What is the issue here can anyone help please???

share|improve this question

migrated from stackoverflow.com Dec 10 '12 at 12:31

This question came from our site for professional and enthusiast programmers.

1  
Did you make sure that your script is executable? chmod +x Subhayan1.cgi –  ddoxey Dec 10 '12 at 4:21
    
@ddoxey - does Windows use chmod? I thought it didn't. –  ghoti Dec 10 '12 at 12:31
    
Yes, you're right windows doesn't have chmod. But I'm pretty sure there's some equivalent. Probably right-click and selecting an executable checkbox. –  ddoxey Dec 10 '12 at 15:24

2 Answers 2

You should the webserver access/error log to see what is the real error.

Are you able to run the cgi script from windows commandline?

For Perl CGI script you should install Perl and CGI.pm.

cmd> C:/xampp/cgi-bin/Subhayan1.cgi

The output should be:

Http 1.1
<doctype...

If everything works fine this point you should be sure that your installed Perl version added as handler for CGI scripts in Apache.

Details:

http://stackoverflow.com/questions/560749/how-do-i-configure-apache2-to-run-perl-cgi-scripts

http://www.ubuntugeek.com/how-to-install-apache2-webserver-with-phpcgi-and-perl-support-in-ubuntu-server.html

share|improve this answer

Try the below codes..it will works fine.

#!"C:\xampp\perl\bin\perl.exe"
use CGI;
$co = new CGI;
print $co->header,
$co->start_html('CGI Example'),
$co->center('welcome to CGI'),
$co->end_html;

(or)

#!"C:\xampp\perl\bin\perl.exe"
use CGI;
$co = new CGI;
print $co->header;

print "
<html>
<title>CGI Example</title>
<head></head>
<body>
 welcome to CGI
</body>
</html>
";
share|improve this answer
2  
Hello! Welcome to Super User! Mind explaining why, this works, not just how? –  Qix Feb 7 '13 at 7:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.