|
Pages: [1]
|
 |
|
Author
|
Topic: Bad CGI Header on Linux.............. (Read 1055 times)
|
|
jfdutcher
|
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
|
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
|
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
|
The "Error 500 - Bad Header line" refers to the "shebang line": #!/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: write %my-linux-script.r read %my-windows-script.r
|
|
|
|
|
Logged
|
|
|
|
|
jfdutcher
|
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
|
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
|
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
|
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
|
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
|
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
|
Try adding -cs to the shebang line #!home/jfdutcher/abyss/abyssws/htdocs/cgi-bin/rebol -cs
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
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
|
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]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2245 Posts in 589 Topics by 2259 Members
Latest Member: edibritrava
|