Home: Perl Programming Help: mod_perl:
Perl CGI script doesn't execute



pranavkojha
New User

Feb 24, 2008, 8:14 AM


Views: 17311
Perl CGI script doesn't execute

I am not able to get desired output in HTML using a small perl script. When I execute the below script it outputs the text fine (using 'perl test.pl' command). However, on my browser, when I key in the address of the script "http://localhost/test.pl", I get output as the script itself. I have given the execute permission for the script but it still doesn't work, also the path of 'perl' is correct. I just want the output as "Perl works!". Here is the script I have been working on,

Code
************************** 
#! /usr/bin/perl

use strict;
use CGI':standard';

print "Content-type:text/html","\n\n";
print "<html><body>";
print "<br>";
print "Perl works!";
print "</body></html>";
**************************

Any help?
System info:
Fedora core 5
Apache server


KevinR
Veteran


Feb 24, 2008, 12:17 PM


Views: 17308
Re: [pranavkojha] Perl CGI script doesn't execute

Normally scripts go in the cgi-bin, not in the root www directory although the server could be setup like that if you wanted to. Google for a tutorial for your specific http server and read about setting it up to run scripts. There are a lot of forums that discuss server topics too so you may want to find a forum that has a topic area for apache.
-------------------------------------------------


hydpm
User

Mar 12, 2008, 2:57 PM


Views: 17276
Re: [pranavkojha] Perl CGI script doesn't execute

make sure the file is in cgi-bin folder. Check in httpd.conf file, the value for the Script Alias for cgi-bin path.

Then check the permission of the file

in the url : http://<host>/cgi-bin/test.pl


KevinR
Veteran


Mar 13, 2008, 12:36 AM


Views: 17274
Re: [pranavkojha] Perl CGI script doesn't execute

not sure if the space in the shebang line would be a problem but I would remove it:

#! /usr/bin/perl

should be:

#!/usr/bin/perl
-------------------------------------------------