Perl files doesn't start.

enginaar

Verified User
Joined
May 20, 2004
Messages
158
Location
Turkiye
Hello,

I've a mymd5.pl perl script under /cgi-bin dir but i can't use it on web. cgi-bin directory's permissions are set by 755. What must i do.
 
Hello,

1/ Make sure the Perl script has \n break format:
Code:
perl -pi -e "s/\r\n/\n/g" youfile.pl
2/ The directory your Perl script resides in must be chowned and chgrped to the user who is running the script (The dir can not be user:apache!!)

3/ Make sure the Perl script itself is chmod 755

4/ ExecCGI must be enabled (via httpd.conf or .htaccess) in the directory you've placed the Perl script

That will usually fix most problems :)

Phi1.
 
Last edited:
If it helps you to find out the problem, i've an output of perl -c command below.


Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at /home/user/public_html/cgi-bin/samplechk.pl line 3.
BEGIN failed--compilation aborted at /home/user/public_html/cgi-bin/samplechk.pl line 3.


I was running this script on my older machine that was running Ensim and Perl 5.6.0. I've had no config to it, it was running with default configuration. There is a /usr/lib/perl5/5.6.0/CGI.pm file on the older machine but i can't find it in my new mach.

Can it be done if i copy the CGI.pm file to the /usr/lib/perl5/5.8.0 directory.
 
Hello,

You'll want to use CPAN to install the CGI module:

# perl -MCPAN -e shell
cpan> install CGI

Phi1.
 
Thanks its working, but i've another problem now.

My protected directories doesn't work.

I checked .htaccess and .htpasswd files and they are OK but i can't view protected directories from web without using any password.
 
Another problem about cgi again. I've find a counter.cgi and want to run it, perl -c counter.cgi output is Syntax OK, but there is a strange string in the error log, when i want to open from web.

Premature end of script headers: /home/user/domains/domain.com/public_html/cgi-bin/counter.cgi
 
having exactly same problems
perl -c script.cgi: syntax ok
when calling the script with explorer, 500 error

error log: [Mon Jun 14 16:26:02 2004] [error] [client 195.xxx.xx.xxx] Premature end of script headers: /home/strandju/domains/xxx/public_html/cgi-bin/perldiver.cgi
 
What did you mean exactly, i couldn't understand. Running root what. Do i have to set owner of the cgi script root:root.
 
no, i mean, when i login as root(ssh)
i run:
$perl <scriptname>.cgi i get html code, so seems to me its working, no errors

Code:
[root@server01 cgi-bin]# perl perldiver.cgi
Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"><head><
title>Perl Diver : Main</title>
<style type="text/css">
<!--/* <![CDATA[ */
        body      {
etc. etc.

when i call the script through the domainname with exploorer i get:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. etc
 
l0rdphi1 said:
Hello,

1/ Make sure the Perl script has \n break format:
Code:
perl -pi -e "s/\r\n/\n/g" youfile.pl
2/ The directory your Perl script resides in must be chowned and chgrped to the user who is running the script (The dir can not be user:apache!!)

3/ Make sure the Perl script itself is chmod 755

4/ ExecCGI must be enabled (via httpd.conf or .htaccess) in the directory you've placed the Perl script

That will usually fix most problems :)

Phi1.
;) -- I bet the problem is one of those.
 
How can i make sure it if it has \n break format. Or how can i change it to that format.

Is this error message: "Premature end of script headers" related to the \n break format?
 
enginaar said:
How can i make sure it if it has \n break format.
Upload it as ascii.
Or how can i change it to that format.
If you've got shell access and if dos2unix is installed on your server, navigate to the subdirectory where the cgi program is located and then do:

$ dos2unix filename

where filename is the name of the file you're converting.
Is this error message: "Premature end of script headers" related to the \n break format?
Do a google on the error message to see some possible causes and fixes.

Jeff
 
l0rdphi1 said:
Hello,

1/ Make sure the Perl script has \n break format:
Code:
perl -pi -e "s/\r\n/\n/g" youfile.pl
2/ The directory your Perl script resides in must be chowned and chgrped to the user who is running the script (The dir can not be user:apache!!)

3/ Make sure the Perl script itself is chmod 755

4/ ExecCGI must be enabled (via httpd.conf or .htaccess) in the directory you've placed the Perl script

That will usually fix most problems :)

Phi1.

All ok! But, script via domain name don't work. What to do?
 
Siple script don't work:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "All work";
 
RosT said:
Siple script don't work:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "All work";

Check your "AddHandler cgi-script .cgi .pl" line in your httpd.conf file if your trying to run it outside of cgi-bin.

with temporary ftp access, I can help more. Let me know if you need further assistance.
 
simple fix...

/usr/bin/perl is linked to /usr/local/bin/perl which is missing.

recreate link with "ln -s /usr/bin/perl5 /usr/bin/perl"

Not exactly sure why perl 5.8 was installed and is now missing, but you should consider reinstalling perl 5.8 in the long run.
 
Back
Top