LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Perl working at command line, but not in Apache (https://www.linuxquestions.org/questions/linux-software-2/perl-working-at-command-line-but-not-in-apache-434418/)

nutthick 04-12-2006 05:50 AM

Perl working at command line, but not in Apache
 
I have a test perl script, that works on my Windoze box (Just says hello) that I have in /var/www/cgi-bin on my Slackware 10.2 box. When I'm in that directory, if I type
Code:

/usr/bin/perl test.pl
then I get the html the script generates on screen.
However, if I call the script from a PC through Apache, I get error 500. The Apache error log says
Code:

[error] (2)No such file or directory: exec of /var/www/cgi-bin/test.pl failed
[error] [client 192.168.0.3] Premature end of script headers: /var/www/cgi-bin/test.pl
[error] [client 192.168.0.3] File does not exist: /var/www/htdocs/favicon.ico

The test script from the install runs perfectly, and I think I understand why. The first line of the sample script is #!/bin/sh, so I think that is running a bash script. My script is below
Code:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>I just wrote a web page using Perl!</H2>";
print "</BODY></HTML>";

So I'm thinking it must be a Apache conf problem. But I can't see anything wrong with that either. Here is the appropriate section of it
Code:

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

    #
    # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "/var/www/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

Can anyone see why this isn't working? Thanks

Alien_Hominid 04-12-2006 06:38 AM

Did you check the permissions of your file?

nutthick 04-12-2006 06:45 AM

I knew someone would mention that :P The file permissions and ownership for both the installed file and my test file are the same, 777. They are owned by root and @smbshares.

nutthick 04-12-2006 07:02 AM

Found the problem. I rewrote the file in vi and it worked. So I used UltraEdit to compare the ascii and Windows was putting in extra 0x0A 0x0D characters at the end of each line, that were throwing the linux system out.

Hope that help someone else


All times are GMT -5. The time now is 07:34 PM.