1

Update: 07/12/13

The script works through command line.

"------extra line" is to show an extra return key stroke in editor.


XAMPP: 1.8.2

Server: Apache 2.4

Issue:

I keep receiving the error "End of script output before headers: hello.pl" for a simple hello world perl script. I'm trying to execute the script via a web server "xampp".

Curious Note:

I can use another Perl script which will initially work. However when I make a simple change such as a space, return or comment "#", the script will no longer function. However if I remove the change and save it the script will work again.

Check List

Confirm correct path to perl Output header (see perl code below) Extra line at end of script (I heard this could resolve issue) Confirmed correct privileges in httpd.config Transferred file via ftp in ASCII

Perl Script:

#!"C:\xampp\perl\bin\perl.exe"

print "Content-Type: text/html\n\n";

print "hello world";

------extra line

httpd.config

<Directory "C:/xampp/htdocs">;
 Options Indexes FollowSymLinks Includes ExecCGI
 AllowOverride All
 Require all granted
</Directory>;

user2038001
  • 111
  • 2
  • 2
  • 6

4 Answers4

1

Maybe your editor changes the line ending characters to windows one.

CGI output needs to be started with HTTP.., two \n then header, then the body between the right HTML codes (Why doesn't my Perl CGI program work on Windows?)

Check the actual chars in a editor that shows you the line endings (like notepad++).

To my best knowledge, the shebang (#!) line is ignored in windows.

Community
  • 1
  • 1
user1126070
  • 5,059
  • 1
  • 16
  • 15
1

The probable cause: http://perl.baczynski.com/wtf/solved-mystery-perl-on-xampp-wont-run-modified-scripts

tl;dr: turn off your COMODO antivirus, or it's sandbox feature.

Lech
  • 11
  • 1
0

Might be a known PHP bug (https://bugs.php.net/bug.php?id=66474). Try different versions of PHP?

David Spector
  • 1,520
  • 15
  • 21
0

Probably this is SELinux blocks. try this

setsebool -P httpd_enable_cgi 1 
chcon -R -t httpd_sys_script_exec_t cgi-bin/your_script.cgi
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
kod
  • 81
  • 1
  • 1
  • Upvoting because I don't think this answer should be downvoted. It's useful for people running an OS with SELinux in *Enforcing* mode. While, the OP's Apache configuration refers to Windows paths, this issue can effect Apache users on **all** platforms. – Anthony Geoghegan Apr 02 '20 at 17:15