[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Httpd, cgi shell scripts not working
From:       Daniel Stonier <d.stonier () gmail ! com>
Date:       2009-09-21 14:03:01
Message-ID: 27dfa3d0909210703k3aa8769by20476640e75ecb67 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Actually, I'd read the documentation when installing on my atom. However,
still couldn't get this to work with the arm system. And the odd thing was
that it was fine with the same busybox build and configuration.
I did get a bit further in debugging though - the only difference between
the two were the bash shells. The atom bash was a known quantity, but I dont
know what they did with the bash on the arm core. Switching from bash to ash
on the arm core got the simple scripts running fine. Curious as to how bash
is knocking it on the head though.
Thanks for the quick replies - it got my head cleared enough to keep
debugging :)
Regards,
Daniel Stonier.

2009/9/19 Denys Vlasenko <vda.linux@googlemail.com>

> On Friday 18 September 2009 18:30, Leonid Lisovskiy wrote:
> > >I'm having a problem getting httpd to run shell scripts - they just
> return
> > >empty screens.
> >
> > Answer is simple - you have to read documentation first ;-)
> >
> > Since some version, busybox's httpd expects that you are responsible
> > for generating HTTP headers inside shell script. I.e. you have to do
> > like this:
> >
> > echo "HTTP/1.0 200 OK
> > Content-type: image/png
> > Connection: close
> > "
> No. You do not _have to_ output it, it's optional.
> httpd will supply "HTTP/1.0 200 OK" if it is not supplied
> by the CGI. Here is the relevant code from httpd.c:
>
>                                } else if (out_cnt >= 4) {
>                                        /* Did CGI add "HTTP"? */
>                                        if (memcmp(rbuf, HTTP_200, 4) != 0)
> {
>                                                /* there is no "HTTP", do it
> ourself */
>                                                if
> (full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1) !=
> sizeof(HTTP_200)-1)
>                                                        break;
>                                        }
>
> But you _have to_ output at least the one empty
> line, to signify end of header.
>
> Here's the doc:
>
> http://hoohoo.ncsa.illinois.edu/cgi/out.html
>
> Parsed headers
>
> The output of scripts begins with a small header.
> This header consists of text lines, in the same format as an HTTP header,
> terminated by a blank line (a line with only a linefeed or CR/LF).
>
>
>
> IOW:
>
> printf "\r\nMinimal CGI example"
> --
> vda
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>

[Attachment #5 (text/html)]

<div>Actually, I&#39;d read the documentation when installing on my atom. However, \
still couldn&#39;t get this to work with the arm system. And the odd thing was that \
it was fine with the same busybox build and configuration.  <br> \
</div><div></div><div>I did get a bit further in debugging though - the only \
difference between the two were the bash shells. The atom bash was a known quantity, \
but I dont know what they did with the bash on the arm core. Switching from bash to \
ash on the arm core got the simple scripts running fine. Curious as to how bash is \
knocking it on the head though.</div> <div></div><div>Thanks for the quick replies - \
it got my head cleared enough to keep debugging \
:)</div><div></div><div>Regards,<br>Daniel Stonier.<br></div><br><div \
class="gmail_quote">2009/9/19 Denys Vlasenko <span dir="ltr">&lt;<a \
href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a>&gt;</span><br> \
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex;"><div class="im">On Friday 18 September 2009 18:30, Leonid \
Lisovskiy wrote:<br> &gt; &gt;I&#39;m having a problem getting httpd to run shell \
scripts - they just return<br> &gt; &gt;empty screens.<br>
&gt;<br>
&gt; Answer is simple - you have to read documentation first ;-)<br>
&gt;<br>
&gt; Since some version, busybox&#39;s httpd expects that you are responsible<br>
&gt; for generating HTTP headers inside shell script. I.e. you have to do<br>
&gt; like this:<br>
&gt;<br>
&gt; echo &quot;HTTP/1.0 200 OK<br>
&gt; Content-type: image/png<br>
&gt; Connection: close<br>
&gt; &quot;<br>
</div>No. You do not _have to_ output it, it&#39;s optional.<br>
httpd will supply &quot;HTTP/1.0 200 OK&quot; if it is not supplied<br>
by the CGI. Here is the relevant code from httpd.c:<br>
<br>
                                                } else if (out_cnt &gt;= 4) {<br>
                                                            /* Did CGI add \
                &quot;HTTP&quot;? */<br>
                                                            if (memcmp(rbuf, \
                HTTP_200, 4) != 0) {<br>
                                                                        /* there is \
                no &quot;HTTP&quot;, do it ourself */<br>
                                                                        if \
                (full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1) != \
                sizeof(HTTP_200)-1)<br>
                                                                                    \
break;<br>  }<br>
<br>
But you _have to_ output at least the one empty<br>
line, to signify end of header.<br>
<br>
Here&#39;s the doc:<br>
<br>
<a href="http://hoohoo.ncsa.illinois.edu/cgi/out.html" \
target="_blank">http://hoohoo.ncsa.illinois.edu/cgi/out.html</a><br> <br>
Parsed headers<br>
<br>
The output of scripts begins with a small header.<br>
This header consists of text lines, in the same format as an HTTP header,<br>
terminated by a blank line (a line with only a linefeed or CR/LF).<br>
<br>
<br>
<br>
IOW:<br>
<br>
printf &quot;\r\nMinimal CGI example&quot;<br>
<font color="#888888">--<br>
vda<br>
</font><div><div class="h5"><br>
_______________________________________________<br>
busybox mailing list<br>
<a href="mailto:busybox@busybox.net">busybox@busybox.net</a><br>
<a href="http://lists.busybox.net/mailman/listinfo/busybox" \
target="_blank">http://lists.busybox.net/mailman/listinfo/busybox</a><br> \
</div></div></blockquote></div><br>



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic