Try commenting out the first print statement.

This works on my Apache/Linux server:

#!/usr/bin/env ruby
print "Content-type: text/html \r\n\r\n"
print "<html><body>Hello world</body></html> \r\n"

This does not (gets malformed script header error in error.log):

#!/usr/bin/env ruby
print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html \r\n\r\n"
print "<html><body>Hello world</body></html> \r\n"



Jon



Date: Tue, 27 Nov 2001 22:41:47 +0900
Posted: Tue, 27 Nov 2001 19:14:17 +0530
From: Bhagavatheeswaran Mahadevan <BMahadevan / NIIT.com>
Reply-To: ruby-talk / ruby-lang.org
Subject: [ruby-talk:26655] Re: CGI
To: ruby-talk / ruby-lang.org (ruby-talk ML)
X-ML-Name: ruby-talk
X-Mail-Count: 26655
X-MLServer: fml [fml 3.0pl#17]; post only (anyone can post)
X-ML-Info: If you have a question, send e-mail with the body
	"help" (without quotes) to the address ruby-talk-ctl / ruby-lang.org;
	help=<mailto:ruby-talk-ctl / ruby-lang.org?body=help>
Content-Type: multipart/mixed;
	boundary="----_=_NextPart_000_01C17749.9BD610E0"
Precedence: bulk

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C17749.9BD610E0
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C17749.9BD610E0"


------_=_NextPart_001_01C17749.9BD610E0
Content-Type: text/plain

I am trying to run this script.........a pretty simpleone

#!/ruby/bin/ruby
print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html \r\n\r\n"
print "<html><body>Hello world</body></html> \r\n"


My ruby.exe is in ruby/bin/ruby

The error.log file says bad header........I am also sending the error.log
file......so u all can help me out.........

 <<error.log>> .



Thanks
Suresh

> -----Original Message-----
> From:	Dave Thomas [SMTP:Dave / PragmaticProgrammer.com]
> Sent:	27 November 2001 19:06
> To:	ruby-talk / ruby-lang.org
> Subject:	[ruby-talk:26653] Re: CGI
> 
> Bhagavatheeswaran Mahadevan <BMahadevan / NIIT.com> writes:
> 
> > using http://localhost/cgi-bin/one.rb but still getting error page as
> > "Internal Server Error" 
> > I have added the comment line in my script file...
> > 
> > #!/ruby/bin/ruby
> > 
> > 
> > but still my code not working............
> > 
> 
> > Could anybody please help me out...do I have to make some changes in the
> > httpd.conf file............
> 
> What does your Apache error.log say? Is the script executable? And is
> your Ruby really in /ruby/bin/ruby (rather than /usr/bin/ruby?)
> 
> 
> Dave

------_=_NextPart_001_01C17749.9BD610E0
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [ruby-talk:26653] Re: CGI</TITLE>
</HEAD>
<BODY>

<P><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">I am trying to run =
this script.........a pretty simpleone</FONT>
</P>

<P><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">#!/ruby/bin/ruby</FONT>
<BR><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">print =
&quot;HTTP/1.0 200 OK\r\n&quot;</FONT>
<BR><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">print =
&quot;Content-type: text/html \r\n\r\n&quot;</FONT>
<BR><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">print =
&quot;&lt;html&gt;&lt;body&gt;Hello world&lt;/body&gt;&lt;/html&gt; =
\r\n&quot;</FONT>
</P>
<BR>

<P><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">My ruby.exe is in =
ruby/bin/ruby</FONT>
</P>

<P><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">The error.log file =
says bad header........I am also sending the error.log file......so u =
all can help me out.........</FONT>
</P>

<P><FONT FACE=3D"Arial" SIZE=3D2 COLOR=3D"#000000"> =
&lt;&lt;error.log&gt;&gt; </FONT><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">.<BR>
</FONT>
</P>
<BR>

<P><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">Thanks</FONT>
<BR><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">Suresh</FONT>
</P>
<UL>
<P><FONT SIZE=3D1 FACE=3D"Arial">-----Original Message-----</FONT>
<BR><B><FONT SIZE=3D1 FACE=3D"Arial">From:&nbsp;&nbsp;</FONT></B> <FONT =
SIZE=3D1 FACE=3D"Arial">Dave Thomas =
[SMTP:Dave / PragmaticProgrammer.com]</FONT>
<BR><B><FONT SIZE=3D1 FACE=3D"Arial">Sent:&nbsp;&nbsp;</FONT></B> <FONT =
SIZE=3D1 FACE=3D"Arial">27 November 2001 19:06</FONT>
<BR><B><FONT SIZE=3D1 =
FACE=3D"Arial">To:&nbsp;&nbsp;&nbsp;&nbsp;</FONT></B> <FONT SIZE=3D1 =
FACE=3D"Arial">ruby-talk / ruby-lang.org</FONT>
<BR><B><FONT SIZE=3D1 =
FACE=3D"Arial">Subject:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT>=
</B> <FONT SIZE=3D1 FACE=3D"Arial">[ruby-talk:26653] Re: CGI</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Bhagavatheeswaran Mahadevan =
&lt;BMahadevan / NIIT.com&gt; writes:</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&gt; using <A =
HREF=3D"http://localhost/cgi-bin/one.rb" =
TARGET=3D"_blank">http://localhost/cgi-bin/one.rb</A> but still getting =
error page as</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; &quot;Internal Server =
Error&quot; </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; I have added the comment line in =
my script file...</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; #!/ruby/bin/ruby</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; but still my code not =
working............</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; </FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&gt; Could anybody please help me =
out...do I have to make some changes in the</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt; httpd.conf =
file............</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">What does your Apache error.log say? =
Is the script executable? And is</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">your Ruby really in /ruby/bin/ruby =
(rather than /usr/bin/ruby?)</FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">Dave</FONT>
</P>
</UL>
</BODY>
</HTML>
------_=_NextPart_001_01C17749.9BD610E0--

------_=_NextPart_000_01C17749.9BD610E0
Content-Type: application/octet-stream;
	name="error.log"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="error.log"

Apache server shutdown initiated...
[Tue Nov 27 17:52:29 2001] [error] [client 127.0.0.1] malformed header =
from script. Bad header=3DHTTP/1.0 200 OK: c:/program files/apache =
group/apache/cgi-bin/one.rb
[Tue Nov 27 18:00:02 2001] [error] [client 127.0.0.1] malformed header =
from script. Bad header=3DHTTP/1.0 200 OK: c:/program files/apache =
group/apache/cgi-bin/one.rb
Apache server shutdown initiated...
[Tue Nov 27 18:02:29 2001] [error] [client 127.0.0.1] malformed header =
from script. Bad header=3DHTTP/1.0 200 OK: c:/program files/apache =
group/apache/cgi-bin/one.rb
[Tue Nov 27 18:02:52 2001] [error] [client 127.0.0.1] attempt to invoke =
directory as script: c:/program files/apache group/apache/cgi-bin
[Tue Nov 27 18:03:24 2001] [error] [client 127.0.0.1] File does not =
exist: c:/program files/apache group/apache/htdocs/one.rb
[Tue Nov 27 18:04:42 2001] [error] [client 127.0.0.1] File does not =
exist: c:/program files/apache group/apache/htdocs/one.rb
[Tue Nov 27 18:04:43 2001] [error] [client 127.0.0.1] File does not =
exist: c:/program files/apache group/apache/htdocs/one.rb
[Tue Nov 27 18:06:55 2001] [error] [client 127.0.0.1] malformed header =
from script. Bad header=3DHTTP/1.0 200 OK: c:/program files/apache =
group/apache/cgi-bin/one.rb
[Tue Nov 27 18:15:54 2001] [error] [client 127.0.0.1] malformed header =
from script. Bad header=3DHTTP/1.0 200 OK: c:/program files/apache =
group/apache/cgi-bin/one.rb
[Tue Nov 27 18:51:32 2001] [error] [client 127.0.0.1] couldn't spawn =
child process: c:/program files/apache group/apache/cgi-bin/one.rb
[Tue Nov 27 18:51:40 2001] [error] [client 127.0.0.1] couldn't spawn =
child process: c:/program files/apache group/apache/cgi-bin/one.rb

------_=_NextPart_000_01C17749.9BD610E0--