2

I am trying to get my CGI scripts running on my web host (which runs on FreeBSD). To debug why I keep getting the dreaded "premature end of script headers" error, their support recommended that I redirect all my output to stderr, rather than printing it. Looking up how to do this, I came across a very old RAMBO ticket about it, but it looks like it was never implemented.

Per some of the answers to this question, it seems like I should be able to do a call {echo Hello, world >&2} to achieve this, but it doesn't work.

How can I write to stderr in REBOL2?

Community
  • 1
  • 1
James Irwin
  • 1,171
  • 8
  • 21

4 Answers4

0

For my CGI-specific scenario, I have a truly awful workaround. Since writing to stderr in Perl (with which I am entirely unfamiliar) is a one-liner, I'm currently calling the REBOL script from Perl and printing its output to stderr from there:

#!/usr/bin/perl 

use strict; 
use warnings; 
use CGI; 

# Note the backticks 
my $the_string = `/home/public/rebol -csw test-reb.cgi`; 

print STDERR $the_string; 
James Irwin
  • 1,171
  • 8
  • 21
0

This webpage has some suggestions http://www.liquidweb.com/kb/apache-error-premature-end-of-script-headers/ to solve your real problem. Perhaps you did not have the headers printed as first thing in your script, this must be the first thing to do. Maybe the rights are not sufficient, or the .r file type was not properly added in your .htaccess as cgi able file. Your (correct!) rebol core exe has not the correct rights. Or your script ends up in an endless loop?

iArnold
  • 333
  • 2
  • 10
0

Some hints to redirect errors for Rebol cgi script: http://www.rebol.com/docs/core23/rebolcore-2.html#section-6.2

JeanLouis
  • 41
  • 1
0

Better late than never... I've just implemented it for Rebol3 in my Rebol fork.

https://github.com/Oldes/Rebol-issues/issues/2468

The syntax will be probably changed a little bit, because I don't like that the system console port is named input, although it is not just for the input.

So far it is:

print 1 ;<- std_out
modify system/ports/input 'error on
print 2 ;<- std_err
modify system/ports/input 'error off
print 3 ;<- std_out
Oldes
  • 937
  • 1
  • 9
  • 24