Server error 500 on simple perl script


#1

I just set up web space and I uploaded a simple perl script as recommended in the docs. I also have set permissions as recommended and I have a .htaccess file with Options +ExecCGI.

I have the same thing set up on another server and with IE8 it tries to download the first.pl file and on Firefox it juat displays the source text.

I can use telnet to execute the script on that server and it appears to be printing the correct header and text. But I can’t connect to the dreamhost.com server.

TIA,

Paul


#2

What does the script look like? (In particular: does it print at least one header line?)


#3

Here is the text of the first.pl script:

#!/usr/bin/perl;
use CGI;
my $query= new CGI;
print $query->header;
print “hello people in my head\r\n”;

When I run it in telnet it prints out

Content-Type: text/html; charset=ISO-8859-1

hello people in my head

I also made a script called second.pl, which writes to a file. The script is:

#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $query= new CGI;
open my $out, ‘>’, “output.txt” or die “File error: $!”;
print $out $query->header;
print $out “\r\nHello, World.\r\n”;
close $out;

And the file contents are as above. But this is on my smart.net server. With the dreamhost server, If I try to run either script on IE8 or Firefox I get the server error. The error logs are something like this:

suexec failure: could not open log file
fopen: Permission denied
Premature end of script headers: first.pl
File does not exist: /home/pes1949/pauleschoen.com/internal_error.html
suexec policy violation: see suexec log for more details
Premature end of script headers: second.pl
File does not exist: /home/pes1949/pauleschoen.com/internal_error.html

When I used chmod 755 second.pl the error changed to the same as for first.pl. AFAIK everything is the same in smart.net and dreamhost.


#4

The semicolon at the end of the first line of first.pl screws things up. So does having DOS-style line endings. Fixing both made the script work.

second.pl, as written, will not work as a CGI script, as it doesn’t actually generate any output. (The fact that it’s writing to output.txt doesn’t count.)


#5

I was amazed that it works. But if I copy the file to another (such as first2.pl) and set permissions 755, it works, but if I edit the file using either editor in net2ftp, it stops working. Can I access a compatible editor? I tried sending the command “pico” but it was not recognized as an FTP command. And I can’t use Telnet. So how do I edit a perl script without DOS-style line endings?

Thanks!