Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Bad CGI Header on Linux..............
Pages: [1] Print
Author Topic: Bad CGI Header on Linux..............  (Read 1055 times)
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Bad CGI Header on Linux..............
« on: June 07, 2007, 07:50:05 PM »

The script below runs fine on Abyss Web Server under Windows....along with others.
Neither this script, nor any script, runs on Abyss Web Server on Linux. How can the Rebol scripts (which are reputed to be cross-platform) be altered on Linux to send a 'good' header  ??

All scripts return this message in the server log:
CGI: [/home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol reline.r ]   URI: /cgi-bin/reline.r?filename=reline.r&Submit=SUBMIT   Bad CGI header line [  [H [JREBOL/Core 2.6.2.4.2]
REBOL terminated
*********************************************************************
The script in question:

#!/home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol -cswq
REBOL []
print {Content-Type: text/html}  ;-- Required Page Header
print " "
print " "
cgi: make object! decode-cgi system/options/cgi/query-string
file: to-file  cgi/filename
write file read file
print ["Filename: " <B> cgi/filename </B> "was rewritten"<P>]
print [</body><html>]
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Bad CGI Header on Linux..............
« Reply #1 on: June 08, 2007, 01:00:22 AM »

Make sure line terminators are correct, Linux does not like a CRLF in the shebang line (ie. the #!... line). You can just use write %file read %file from REBOL to fix it.
Logged
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Re: Bad CGI Header on Linux..............
« Reply #2 on: June 12, 2007, 09:38:15 PM »

Well, it doesn't get much simpler than this script....but using all variations of the print header line observable in the script library still produces only the "Error 500 - Bad Header line" results back from the server.
I'm kinda convinced Rebol cannot output a header acceptable to a Linux server, at least not the Linux Abyss Web server.

#!/home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol -cswq
REBOL []
print "Content-Type: text/html^/"  ;-- Required Page Header
cgi: make object! decode-cgi system/options/cgi/query-string
print [
    <html><body><h2>"CGI Results:"</h2>]
file: to-file  cgi/filename
write file read file
print ["Filename: " <B> cgi/filename </B> "was rewritten"<P>]
print [</body></html>]
Logged
PeterWood
Newbie
*
Offline Offline

Posts: 28


View Profile
Re: Bad CGI Header on Linux..............
« Reply #3 on: June 13, 2007, 12:12:08 AM »

The "Error 500 - Bad Header line" refers to the "shebang line":

Code:
#!/home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol -cswq

The problem isn't in your REBOL code; it's in the above line as Gabriele indicated.

If you created the script under Windows, the lines will end with CRLF and you need to convert the script to Unix line endings. REBOL does this automatically so one easy way of converting the line endings of a file is to run a one-line script that reads and writes the file or from the REBOL console.

So to convert a Windows file when running REBOL on Linux:

Code:
write %my-linux-script.r read %my-windows-script.r
Logged
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Re: Bad CGI Header on Linux..............
« Reply #4 on: June 13, 2007, 05:30:52 PM »

I can assure you......I did run the read file - write file  exercise on every script brought over from Windows...and did it using the Linux version of Rebol executable on Linux in the View console window.

J.D.
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Bad CGI Header on Linux..............
« Reply #5 on: June 14, 2007, 12:38:55 AM »

Ok, so there must be something else your web server is not liking. Are the scripts executable (chmod a+x file.cgi)? What happens when you run them from the command line? (./file.cgi) What happens if you try to run them as the web server's user?
Logged
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Re: Bad CGI Header on Linux..............
« Reply #6 on: June 14, 2007, 06:19:22 PM »

Running from the command line gives the following:

do %/home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/reline.r


Content-Type: text/html

** Script Error: decode-cgi expected args argument of type: any-string
** Where: halt-view
** Near: cgi: make object! decode-cgi system/options/cgi/query-string
>>

Logged
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Re: Bad CGI Header on Linux..............
« Reply #7 on: June 14, 2007, 07:43:57 PM »

This is interesting...... I save an 'empty'  Rebol script file, a  dot-r  (.r)  file and then call for it from the browser.
The same "Bad header line" Error 500 results.......that certainly says something...but I don't yet know what.  I posed my issue to the Aprelium (Abyss)  site for any input they might have as the authors of the web server. 
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Bad CGI Header on Linux..............
« Reply #8 on: June 15, 2007, 02:02:54 AM »

Ok, so your problem number one is that the Abyss server is not giving you an empty string as the query (you probably get NONE there). So you need to change your script for that (ie. decode-cgi any [system/options/cgi/query-string ""] instead of decode-cgi system/options/cgi/query-string).

An empty script will not work because you need to print the header in any case.
Logged
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Re: Bad CGI Header on Linux..............
« Reply #9 on: June 16, 2007, 05:45:04 PM »

One and all....This is the comment from the Aprelium Server vendor (author of Abyss web server) as explanation for my bad header issue......now if anyone can say how I execute Rebol in 'quiet' as suggested...I may see output yet ....or does gettinf the 'arguments' back into the picture accomplish that  ??

Dear John,

The key to the solution is in the error message:

 > CGI:
 > /home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol
 > reline.r ]   
 > URI:
 > /cgi-bin/reline.r?filename=cgidump.r&Submit=SUBMIT   Bad
 > CGI header line [  [H [JREBOL/Core 2.6.2.4.2]

Actually Abyss Web Server complained about a bad CGI header line it
received and included it. It was "  [H [JREBOL/Core 2.6.2.4.2" which
suggest that Rebol was outputting its name and version information
before starting the execution which confuses Abyss Web Server and
interferes with the CGI output.

So the solution is to make Rebol not output its name/version
information
(quiet mode).

We also noticed that in the first line of the script you have included
the Rebol executable path with an extra set of arguments. This line is
ignored by Abyss Web Server and by Linux in your configuration and
these arguments are never taken into account.

So what you'll have to do is to add them to the "Arguments" parameters
in the Rebol interpreter declaration. So simply enter in "Arguments":

-cswq

And validate. These arguments seem to be what you need to get rid of
that extra name/version line that is breaking the CGI output.

Does it work now as with the Windows version?

We'll be waiting for your reply.

Kind regards,

Support Team
Logged
Sunanda
Full Member
***
Offline Offline

Posts: 100


View Profile
Re: Bad CGI Header on Linux..............
« Reply #10 on: June 17, 2007, 08:13:40 AM »

Try adding -cs to the shebang line

Code:
#!home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol -cs
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Bad CGI Header on Linux..............
« Reply #11 on: June 18, 2007, 04:09:27 AM »

We also noticed that in the first line of the script you have included
the Rebol executable path with an extra set of arguments. This line is
ignored by Abyss Web Server and by Linux in your configuration and
these arguments are never taken into account.

So what you'll have to do is to add them to the "Arguments" parameters
in the Rebol interpreter declaration. So simply enter in "Arguments":

-cswq

And validate. These arguments seem to be what you need to get rid of
that extra name/version line that is breaking the CGI output.

The key is the above statement. Abyss ignores the shebang line. (That is, they are silly.) (I wonder why you don't just use Apache actually, or Cheyenne at this point.) So you have to configure Abyss correctly to run rebol with the -c flag.
Logged
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
Re: Bad CGI Header on Linux..............
« Reply #12 on: June 18, 2007, 08:45:47 AM »

Many thanks for all input...I will definitely give Cheyenne a try as I'm interested in runnning as much Rebol code as possible.  I have probably made a mistake in setting up on the GoDaddy host with my Rebol blog.r script. They are one of  a few who tolerated the Rebol binary in my CGI directory...but....so far the 'classic' error of merely returning the script file 'content' rather than executing it occurs.

I had thought the shebang line would  be digested and cause Rebol to run....but since Rebol is  not one of their 'supported' scripters.....I gather that shebang input will only be functional if the hoster has made the server sensitive to it.....it's not merely that  Linux canl handle it (the acoount is on Linux servers).
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Bad CGI Header on Linux..............
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 08, 2008, 02:48:35 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2245 Posts in 589 Topics by 2259 Members
Latest Member: edibritrava

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc